List of usage examples for android.content Intent FLAG_ACTIVITY_NEW_TASK
int FLAG_ACTIVITY_NEW_TASK
To view the source code for android.content Intent FLAG_ACTIVITY_NEW_TASK.
Click Source Link
From source file:com.chefsglass.StopwatchService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { if (mLiveCard == null) { mLiveCard = new LiveCard(this, LIVE_CARD_TAG); new GetRecipeTask(new GetRecipeRequest(1l)).execute(); // Keep track of the callback to remove it before unpublishing. mCallback = new RecipeDrawer(this); mLiveCard.setDirectRenderingEnabled(true).getSurfaceHolder().addCallback(mCallback); Intent menuIntent = new Intent(this, MenuActivity.class); menuIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); mLiveCard.setAction(PendingIntent.getActivity(this, 0, menuIntent, 0)); mLiveCard.attach(this); mLiveCard.publish(PublishMode.REVEAL); } else {//from ww w. j a v a 2s. c om mLiveCard.navigate(); } return START_STICKY; }
From source file:com.manning.androidhacks.hack023.HackApplication.java
public Account getCurrentAccount() { AccountManager accountManager = AccountManager.get(this); Account[] accounts = accountManager.getAccountsByType(AuthenticatorActivity.PARAM_ACCOUNT_TYPE); if (accounts.length > 0) { return accounts[0]; } else {// ww w.j av a 2s . c om Intent intent = new Intent(this, MainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); return null; } }
From source file:com.xmartlabs.cordova.market.Market.java
/** * Open the appId details on Google Play . * * @param appId/*from w ww . ja va 2 s .co m*/ * Application Id on Google Play. * E.g.: com.google.earth */ private void openGooglePlay(String appId) throws android.content.ActivityNotFoundException { Context context = this.cordova.getActivity().getApplicationContext(); Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appId)); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); }
From source file:com.appnexus.opensdk.PBImplementation.java
private static void launchApp(Context context) { Intent intent = new Intent(Intent.ACTION_VIEW, URI_LAUNCH_APP); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); try {/*from w w w .j a va 2 s . co m*/ context.startActivity(intent); } catch (ActivityNotFoundException e) { Clog.w(Clog.baseLogTag, Clog.getString(R.string.opening_url_failed, URI_LAUNCH_APP.toString())); } }
From source file:Main.java
public static void openFileInExtApp(Context context, File url) throws IOException { // Create URI File file = url;/*from www .j a v a 2 s .co m*/ Uri uri = Uri.fromFile(file); Intent intent = new Intent(Intent.ACTION_VIEW); // Check what kind of file you are trying to open, by comparing the url with extensions. // When the if condition is matched, plugin sets the correct intent (mime) type, // so Android knew what application to use to open the file if (url.toString().contains(".doc") || url.toString().contains(".docx")) { // Word document intent.setDataAndType(uri, "application/msword"); } else if (url.toString().contains(".pdf")) { // PDF file intent.setDataAndType(uri, "application/pdf"); } else if (url.toString().contains(".ppt") || url.toString().contains(".pptx")) { // Powerpoint file intent.setDataAndType(uri, "application/vnd.ms-powerpoint"); } else if (url.toString().contains(".xls") || url.toString().contains(".xlsx")) { // Excel file intent.setDataAndType(uri, "application/vnd.ms-excel"); } else if (url.toString().contains(".zip") || url.toString().contains(".rar")) { // WAV audio file intent.setDataAndType(uri, "application/x-wav"); } else if (url.toString().contains(".rtf")) { // RTF file intent.setDataAndType(uri, "application/rtf"); } else if (url.toString().contains(".wav") || url.toString().contains(".mp3")) { // WAV audio file intent.setDataAndType(uri, "audio/x-wav"); } else if (url.toString().contains(".gif")) { // GIF file intent.setDataAndType(uri, "image/gif"); } else if (url.toString().contains(".jpg") || url.toString().contains(".jpeg") || url.toString().contains(".png")) { // JPG file intent.setDataAndType(uri, "image/jpeg"); } else if (url.toString().contains(".txt")) { // Text file intent.setDataAndType(uri, "text/plain"); } else if (url.toString().contains(".html")) { // Html file intent.setDataAndType(uri, "text/html"); } else if (url.toString().contains(".3gp") || url.toString().contains(".mpg") || url.toString().contains(".mpeg") || url.toString().contains(".mpe") || url.toString().contains(".mp4") || url.toString().contains(".avi")) { // Video files intent.setDataAndType(uri, "video/*"); } else { //if you want you can also define the intent type for any other file //additionally use else clause below, to manage other unknown extensions //in this case, Android will show all applications installed on the device //so you can choose which application to use intent.setDataAndType(uri, "*/*"); } intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); }
From source file:com.prey.json.actions.Geofencing.java
public void stop(Context ctx, List<ActionResult> lista, JSONObject parameters) { Bundle bundle = new Bundle(); bundle.putInt("type", ProxAlertActivity.STOP); Intent popup = new Intent(ctx, ProxAlertActivity.class); popup.putExtras(bundle);//w ww . jav a 2s . c o m popup.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); ctx.startActivity(popup); PreyLogger.i("Finish Geofencing stop"); }
From source file:com.arellomobile.android.push.PushGCMIntentService.java
private static void generateNotification(Context context, Intent intent, Handler handler) { Bundle extras = intent.getExtras();// ww w. ja v a 2s .c o m if (extras == null) { return; } extras.putBoolean("foregroud", GeneralUtils.isAppOnForeground(context)); String title = (String) extras.get("title"); String link = (String) extras.get("l"); // empty message with no data Intent notifyIntent; if (link != null) { // we want main app class to be launched notifyIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(link)); notifyIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); } else { notifyIntent = new Intent(context, PushHandlerActivity.class); notifyIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); // pass all bundle notifyIntent.putExtra("pushBundle", extras); } // first string will appear on the status bar once when message is added CharSequence appName = context.getPackageManager().getApplicationLabel(context.getApplicationInfo()); if (null == appName) { appName = ""; } NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); NotificationFactory notificationFactory; //is this banner notification? String bannerUrl = (String) extras.get("b"); //also check that notification layout has been placed in layout folder int layoutId = context.getResources().getIdentifier(BannerNotificationFactory.sNotificationLayout, "layout", context.getPackageName()); if (layoutId != 0 && bannerUrl != null) { notificationFactory = new BannerNotificationFactory(context, extras, appName.toString(), title, PushManager.sSoundType, PushManager.sVibrateType); } else { notificationFactory = new SimpleNotificationFactory(context, extras, appName.toString(), title, PushManager.sSoundType, PushManager.sVibrateType); } notificationFactory.generateNotification(); notificationFactory.addSoundAndVibrate(); notificationFactory.addCancel(); Notification notification = notificationFactory.getNotification(); notification.contentIntent = PendingIntent.getActivity(context, 0, notifyIntent, PendingIntent.FLAG_UPDATE_CURRENT); if (mSimpleNotification) { manager.notify(PushManager.MESSAGE_ID, notification); } else { manager.notify(PushManager.MESSAGE_ID++, notification); } generateBroadcast(context, extras); }
From source file:com.phonegap.plugins.ExternalAppLauncher.ExternalAppLauncher.java
/** * launch market to certain app//from www.j a v a2 s .c o m */ private boolean launchMarket(Context context, String packageName) { Log.d(pluginName, "Launch Market"); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse("market://details?id=" + packageName)); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); Boolean result = false; try { context.startActivity(intent); result = true; } catch (Exception ex) { Log.d(pluginName, ex.getMessage()); result = false; } return result; }
From source file:com.appteam.nimbus.activity.homeActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); personalData = new PersonalData(this); if (personalData.getStatus() == false) { Intent i = new Intent(homeActivity.this, Login.class); i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(i);/*from w ww. j a v a 2s . c o m*/ finish(); } setContentView(R.layout.activity_home); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); ImageView icon1 = (ImageView) findViewById(R.id.icon1); ImageView arrow1 = (ImageView) findViewById(R.id.arrow1); ImageView icon2 = (ImageView) findViewById(R.id.icon2); ImageView arrow2 = (ImageView) findViewById(R.id.arrow2); ImageView icon3 = (ImageView) findViewById(R.id.icon3); ImageView arrow3 = (ImageView) findViewById(R.id.arrow3); ImageView icon4 = (ImageView) findViewById(R.id.icon4); ImageView arrow4 = (ImageView) findViewById(R.id.arrow4); ImageView icon5 = (ImageView) findViewById(R.id.icon5); ImageView arrow5 = (ImageView) findViewById(R.id.arrow5); final int newColor = getResources().getColor(R.color.new_color); icon1.setColorFilter(newColor, PorterDuff.Mode.SRC_ATOP); arrow1.setColorFilter(newColor, PorterDuff.Mode.SRC_ATOP); icon2.setColorFilter(newColor, PorterDuff.Mode.SRC_ATOP); arrow2.setColorFilter(newColor, PorterDuff.Mode.SRC_ATOP); icon3.setColorFilter(newColor, PorterDuff.Mode.SRC_ATOP); arrow3.setColorFilter(newColor, PorterDuff.Mode.SRC_ATOP); icon4.setColorFilter(newColor, PorterDuff.Mode.SRC_ATOP); arrow4.setColorFilter(newColor, PorterDuff.Mode.SRC_ATOP); icon5.setColorFilter(newColor, PorterDuff.Mode.SRC_ATOP); arrow5.setColorFilter(newColor, PorterDuff.Mode.SRC_ATOP); DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); drawer.setDrawerListener(toggle); toggle.syncState(); NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); findViewById(R.id.department).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { startActivity(new Intent(homeActivity.this, DepartmentalTeam.class)); overridePendingTransition(R.anim.open_next, R.anim.open_main); } }); findViewById(R.id.coreteam).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { startActivity(new Intent(homeActivity.this, CoreTeamActivity.class)); overridePendingTransition(R.anim.open_next, R.anim.open_main); } }); findViewById(R.id.event).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { startActivity(new Intent(homeActivity.this, EventActivity.class)); overridePendingTransition(R.anim.open_next, R.anim.open_main); } }); findViewById(R.id.welcome).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(homeActivity.this, AboutNimbusSplash.class); intent.putExtra(ABOUT_NIMBUS, "rule"); startActivity(intent); } }); findViewById(R.id.sponsors).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { startActivity(new Intent(homeActivity.this, SponserActivity.class)); overridePendingTransition(R.anim.open_next, R.anim.open_main); } }); }
From source file:gov.nasa.arc.geocam.talk.UIUtils.java
/** * Invoke "home" action, returning to {@link GeoCamTalkActivity}. * * @param context The activity context to send the intent from. *///from w w w .jav a 2s . c o m public static void goHome(Context context) { final Intent intent = new Intent(context, GeoCamTalkActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); }