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.wso2.mobile.mdm.services.PolicyTester.java
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) public PolicyTester(Context context, JSONArray recJArray, int type, String msgID) { this.context = context; devicePolicyManager = (DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE); appList = new ApplicationManager(context); deviceInfo = new DeviceInfo(context); deviceState = new PhoneState(context); if (type == POLICY_MONITOR_TYPE_NO_ENFORCE_RETURN) { IS_ENFORCE = false;/*from w w w .j a v a2s. c om*/ } else if (type == POLICY_MONITOR_TYPE_NO_ENFORCE_MESSAGE_RETURN) { IS_ENFORCE = false; } else if (type == POLICY_MONITOR_TYPE_ENFORCE_RETURN) { IS_ENFORCE = true; } else { IS_ENFORCE = false; type = POLICY_MONITOR_TYPE_NO_ENFORCE_MESSAGE_RETURN; } SharedPreferences mainPref = context.getSharedPreferences("com.mdm", Context.MODE_PRIVATE); policy = mainPref.getString("policy", ""); try { JSONArray jArray = null; if (recJArray != null) { jArray = recJArray; } else { jArray = new JSONArray(policy); } Log.e("POLICY ARAY : ", jArray.toString()); for (int i = 0; i < jArray.length(); i++) { JSONObject policyObj = (JSONObject) jArray.getJSONObject(i); if (policyObj.getString("data") != null && policyObj.getString("data") != "") { testPolicy(policyObj.getString("code"), policyObj.getString("data")); } } JSONObject rootObj = new JSONObject(); try { if (deviceInfo.isRooted()) { rootObj.put("status", false); } else { rootObj.put("status", true); } rootObj.put("code", "notrooted"); finalArray.put(rootObj); } catch (JSONException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } Log.e("MONITOR POLICY : ", policy); Log.e("MONITOR USER MESSAGE : ", usermessage); //Display an alert to the user about policy violation if (policy != null && policy != "") { if (usermessage != null && usermessage != "" && type == POLICY_MONITOR_TYPE_NO_ENFORCE_MESSAGE_RETURN) { Intent intent = new Intent(context, AlertActivity.class); intent.putExtra("message", usermessage); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); } } returnJSON.put("code", CommonUtilities.OPERATION_POLICY_MONITOR); returnJSON.put("data", finalArray); Map<String, String> params = new HashMap<String, String>(); params.put("code", CommonUtilities.OPERATION_POLICY_MONITOR); params.put("msgID", msgID); params.put("status", "200"); params.put("data", finalArray.toString()); ServerUtilities.pushData(params, context); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:com.zxing.qrcode.decoding.CaptureActivityHandler.java
@Override public void handleMessage(Message message) { switch (message.what) { case R.id.auto_focus: // Log.d(TAG, "Got auto-focus message"); // When one auto focus pass finishes, start another. This is the // closest thing to // continuous AF. It does seem to hunt a bit, but I'm not sure what // else to do. if (state == State.PREVIEW) { CameraManager.get().requestAutoFocus(this, R.id.auto_focus); }//from ww w. j a v a 2 s . c o m break; case R.id.restart_preview: Log.d(TAG, "Got restart preview message"); restartPreviewAndDecode(); break; case R.id.decode_succeeded: Log.d(TAG, "Got decode succeeded message"); state = State.SUCCESS; Bundle bundle = message.getData(); Bitmap barcode = bundle == null ? null : (Bitmap) bundle.getParcelable(DecodeThread.BARCODE_BITMAP); final String str_result = ((Result) message.obj).getText(); System.out.println("====str_result====" + str_result); String match = "^[0-9]{13}"; boolean b = str_result.matches(match); // Toast.makeText(activity, ""+b, 1).show(); // activity.handleDecode((Result) message.obj, barcode); if (b) { String url = RequestUrls.TIAOXING_CODE_URL.replace("[code]", str_result); FinalHttp fh = new FinalHttp(); fh.get(url, new AjaxCallBack<Object>() { @Override public void onSuccess(Object t) { // TODO Auto-generated method stub super.onSuccess(t); try { System.out.println("===TIAOXING_CODE_URL====" + new JSONObject(t.toString())); Intent tagIntent = new Intent(activity, TagdetialActivity.class); tagIntent.putExtra("jsonStr", t.toString()); tagIntent.putExtra("barcodes", str_result); tagIntent.putExtra("eid", eid); tagIntent.putExtra("tag_ids", tag_ids); activity.startActivity(tagIntent); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } @Override public void onFailure(Throwable t, String strMsg) { // TODO Auto-generated method stub super.onFailure(t, strMsg); } }); } else { try { Intent intent = new Intent(Intent.ACTION_VIEW); // //// intent.setPackage("com.tencent.mm");// intent.putExtra(Intent.EXTRA_SUBJECT, "share"); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // // // intent.setData(Uri.parse("http://weixin.qq.com/r/o3w_sRvEMSVOhwrSnyCH")); intent.setData(Uri.parse(str_result)); activity.startActivity(intent); } catch (Exception e) { Toast.makeText(activity, R.string.no_wechat_rem, Toast.LENGTH_SHORT).show(); } } break; case R.id.decode_failed: // We're decoding as fast as possible, so when one decode fails, // start another. state = State.PREVIEW; CameraManager.get().requestPreviewFrame(decodeThread.getHandler(), R.id.decode); break; case R.id.return_scan_result: Log.d(TAG, "Got return scan result message"); activity.setResult(Activity.RESULT_OK, (Intent) message.obj); activity.finish(); break; } }
From source file:com.cloverstudio.spika.GCMIntentService.java
@SuppressWarnings("deprecation") public void triggerNotification(Context context, String message, String fromName, Bundle pushExtras) { if (fromName != null) { final NotificationManager notificationManager = (NotificationManager) getSystemService( NOTIFICATION_SERVICE);/*from ww w . j a v a 2 s. c om*/ Notification notification = new Notification(R.drawable.icon_notification, message, System.currentTimeMillis()); notification.number = mNotificationCounter + 1; mNotificationCounter = mNotificationCounter + 1; Intent intent = new Intent(this, SplashScreenActivity.class); intent.replaceExtras(pushExtras); intent.putExtra(Const.PUSH_INTENT, true); intent.setAction(Long.toString(System.currentTimeMillis())); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_FROM_BACKGROUND | Intent.FLAG_ACTIVITY_TASK_ON_HOME); PendingIntent pendingIntent = PendingIntent.getActivity(this, notification.number, intent, PendingIntent.FLAG_UPDATE_CURRENT); notification.setLatestEventInfo(this, context.getString(R.string.app_name), message, pendingIntent); notification.defaults |= Notification.DEFAULT_VIBRATE; notification.defaults |= Notification.DEFAULT_SOUND; notification.flags |= Notification.FLAG_AUTO_CANCEL; String notificationId = Double.toString(Math.random()); notificationManager.notify(notificationId, 0, notification); } }
From source file:io.samsungsami.example.SAMInBLEws.SAMIDeviceActivity.java
private void startLoginActivity() { SAMISession.getInstance().reset();/* w ww. ja v a 2 s. co m*/ Intent activityIntent = new Intent(this, SAMILoginActivity.class); activityIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); startActivity(activityIntent); finish(); }
From source file:com.android.settings.locationprivacy.LocationPrivacyAdvancedSettings.java
private void addNotification(int id, int textID) { String text = getResources().getString(textID); Intent intent = new Intent(getActivity(), getActivity().getClass()); intent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT, LocationPrivacySettings.class.getName()); intent.putExtra(PreferenceActivity.EXTRA_NO_HEADERS, true); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); PendingIntent pIntent = PendingIntent.getActivity(getActivity(), 0, intent, 0); Notification noti = new Notification.Builder(getActivity()) .setContentTitle(getResources().getString(R.string.lp_webservice_notification_title)) .setSmallIcon(R.drawable.ic_settings_locationprivacy) .setStyle(new Notification.BigTextStyle().bigText(text)).setContentIntent(pIntent) .setAutoCancel(true).build(); NotificationManager notificationManager = (NotificationManager) getSystemService( getActivity().NOTIFICATION_SERVICE); notificationManager.cancel(WEBSERVICE_ERROR); notificationManager.cancel(WEBSERVICE_OK); notificationManager.cancel(GOOGLE_PLAY); notificationManager.notify(id, noti); }
From source file:com.google.android.apps.muzei.featuredart.FeaturedArtSource.java
@Override protected void onCustomCommand(int id) { super.onCustomCommand(id); if (COMMAND_ID_SHARE == id) { Artwork currentArtwork = getCurrentArtwork(); if (currentArtwork == null) { LOGW(TAG, "No current artwork, can't share."); new Handler(Looper.getMainLooper()).post(new Runnable() { @Override/* w w w . ja v a2 s .c o m*/ public void run() { Toast.makeText(FeaturedArtSource.this, R.string.featuredart_source_error_no_artwork_to_share, Toast.LENGTH_SHORT).show(); } }); return; } String detailUrl = ("initial".equals(currentArtwork.getToken())) ? "http://www.wikipaintings.org/en/vincent-van-gogh/the-starry-night-1889" : currentArtwork.getViewIntent().getDataString(); String artist = currentArtwork.getByline().replaceFirst("\\.\\s*($|\\n).*", "").trim(); Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.setType("text/plain"); shareIntent.putExtra(Intent.EXTRA_TEXT, "My Android wallpaper today is '" + currentArtwork.getTitle().trim() + "' by " + artist + ". #MuzeiFeaturedArt\n\n" + detailUrl); shareIntent = Intent.createChooser(shareIntent, "Share artwork"); shareIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(shareIntent); } else if (COMMAND_ID_DEBUG_INFO == id) { long nextUpdateTimeMillis = getSharedPreferences().getLong("scheduled_update_time_millis", 0); final String nextUpdateTime; if (nextUpdateTimeMillis > 0) { Date d = new Date(nextUpdateTimeMillis); nextUpdateTime = SimpleDateFormat.getDateTimeInstance().format(d); } else { nextUpdateTime = "None"; } new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { Toast.makeText(FeaturedArtSource.this, "Next update time: " + nextUpdateTime, Toast.LENGTH_LONG) .show(); } }); } }
From source file:com.magnet.mmx.client.MMXWakeupIntentService.java
private void invokeNotificationForPush(GCMPayload payload) { // Launch the activity with action=MAIN, category=DEFAULT. Make sure that // it has DEFAULT category declared in AndroidManifest.xml intent-filter. PendingIntent intent = PendingIntent.getActivity(this.getApplicationContext(), 0, new Intent(Intent.ACTION_MAIN).setPackage(this.getPackageName()) .addCategory(Intent.CATEGORY_DEFAULT) // it is redundant .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) .addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED), PendingIntent.FLAG_UPDATE_CURRENT); // If title is not specified, use the app name (compatible with iOS push notification) String title = (payload.getTitle() == null) ? this.getApplicationInfo().name : payload.getTitle(); Notification.Builder noteBuilder = new Notification.Builder(this).setContentIntent(intent) .setAutoCancel(true).setWhen(System.currentTimeMillis()).setContentTitle(title) .setContentText(payload.getBody()); if (payload.getSound() != null) { // TODO: cannot handle custom sound yet; use notification ring tone. noteBuilder.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)); }/*from ww w .j av a 2s . c o m*/ if (payload.getIcon() != null) { noteBuilder.setSmallIcon( this.getResources().getIdentifier(payload.getIcon(), "drawable", this.getPackageName())); } else { noteBuilder.setSmallIcon(this.getApplicationInfo().icon); } if (payload.getBadge() != null) { noteBuilder.setNumber(payload.getBadge()); } NotificationManager noteMgr = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE); noteMgr.notify(sNoteId++, noteBuilder.build()); }
From source file:com.NotifyMe.GcmIntentService.java
private void sendNotificationWithExtras(Bundle extras) { String message = extras.getString("message"); String service = extras.getString("service"); String type = extras.getString("type"); String title = "NotifyMe [" + service + "]"; mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE); PendingIntent contentIntent;/*from ww w . j a v a 2 s . c o m*/ if (service.equals("Reddit")) { Intent resultIntent = new Intent(Intent.ACTION_VIEW); String url = "http://reddit.com"; if (type.equals("reddit-front-page")) { if (Integer.parseInt(extras.getString("count")) == 1) { try { JSONArray posts = new JSONArray(extras.getString("links")); url = posts.getJSONObject(0).getString("url"); message = posts.getJSONObject(0).getString("title"); } catch (JSONException e) { url = "http://reddit.com"; } } else { url = "http://reddit.com"; } } else if (type.equals("user-comment") || type.equals("user-submission")) { url = extras.getString("link"); } resultIntent.setData(Uri.parse(url)); contentIntent = PendingIntent.getActivity(this, 0, resultIntent, Intent.FLAG_ACTIVITY_NEW_TASK); } else if (service.equals("weather")) { Intent resultIntent; Intent weatherIntent = getWeatherAppIntent(); if (weatherIntent != null) { resultIntent = weatherIntent; } else { resultIntent = new Intent(Intent.ACTION_VIEW); String url = "http://weather.com/"; resultIntent.setData(Uri.parse(url)); } contentIntent = PendingIntent.getActivity(this, 0, resultIntent, Intent.FLAG_ACTIVITY_NEW_TASK); } else if (service.equals("poly")) { Intent resultIntent = new Intent(Intent.ACTION_VIEW); String url = "https://www4.polymtl.ca/poly/poly.html"; resultIntent.setData(Uri.parse(url)); contentIntent = PendingIntent.getActivity(this, 0, resultIntent, Intent.FLAG_ACTIVITY_NEW_TASK); } else if (service.equals("github")) { Intent resultIntent = new Intent(Intent.ACTION_VIEW); String url = extras.getString("link"); resultIntent.setData(Uri.parse(url)); contentIntent = PendingIntent.getActivity(this, 0, resultIntent, Intent.FLAG_ACTIVITY_NEW_TASK); } else { contentIntent = PendingIntent.getActivity(this, 0, new Intent(this, MainActivity.class), 0); } NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_stat_gcm).setContentTitle(title).setAutoCancel(true) .setStyle(new NotificationCompat.BigTextStyle().bigText(message)).setContentText(message) .setDefaults(Notification.DEFAULT_VIBRATE).setOnlyAlertOnce(true); mBuilder.setContentIntent(contentIntent); mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build()); }
From source file:com.raffaele.squarecash4glass.CVVConfirmActivity.java
private void doLaunchTransactionCompleted() { // startActivity(new Intent(this, // ContactActivity.class).addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY|Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_CLEAR_TASK)); startActivity(new Intent(this, TransactionCompleted.class).addFlags( Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK)); }
From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.LinkObj.java
@Override public void activate(Context context, SignedObj obj) { JSONObject content = obj.getJson();// w w w . ja v a 2 s . c o m //linkify should have picked it up already but if we are in TV mode we //still need to activate Intent intent = new Intent(Intent.ACTION_VIEW); String text = content.optString(URI); //some shared links come in with two lines of text "title\nuri" //for example google maps does this and passes that same value as both the //uri and title //launch the first thing that looks like a link Matcher m = p.matcher(text); while (m.find()) { Uri uri = Uri.parse(m.group()); String scheme = uri.getScheme(); if (scheme != null && (scheme.equalsIgnoreCase("http") || scheme.equalsIgnoreCase("https"))) { String type = content.optString(MIME_TYPE); if (type != null && type.length() > 0) { intent.setDataAndType(uri, type); } else { intent.setData(uri); } if (!(context instanceof Activity)) { intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); } try { context.startActivity(intent); } catch (ActivityNotFoundException e) { String msg; if (type != null) msg = "A third party application that supports " + type + " is required."; else msg = "A third party application that supports " + uri.getScheme() + " is required."; Toast.makeText(context, msg, Toast.LENGTH_SHORT).show(); } return; } } }