List of usage examples for android.content Intent setFlags
public @NonNull Intent setFlags(@Flags int flags)
From source file:com.dcs.fakecurrencydetector.MainActivity.java
public void AppExit() { this.finish(); Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_HOME); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent);// w w w. j a v a 2 s. c o m /*int pid = android.os.Process.myPid();=====> use this if you want to kill your activity. But its not a good one to do. android.os.Process.killProcess(pid);*/ }
From source file:com.gigathinking.simpleapplock.ResetUnlockMethod.java
@Override public void onBackPressed() { finish();/* w w w . j av a2 s . c o m*/ Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_HOME); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); }
From source file:samples.piggate.com.piggateCompleteExample.Activity_Main.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); _piggate = new Piggate(this, null); //Initialize a Piggate object getSupportActionBar().setTitle("Piggate Offers Demo"); networkErrorDialog = new AlertDialog.Builder(this).create(); networkErrorDialog.setTitle("Network error"); networkErrorDialog.setMessage("There is an error with the network connection"); networkErrorDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() { @Override/* w w w.java2s .c o m*/ public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); setContentView(R.layout.activity_main); final Button login = (Button) findViewById(R.id.buttonloginmain); final Button register = (Button) findViewById(R.id.buttonregistermain); //onClick listener of the login button: go to Activity_SingIn login.setOnClickListener(new View.OnClickListener() { @Override synchronized public void onClick(View v) { Intent slideactivity = new Intent(Activity_Main.this, Activity_SingIn.class); slideactivity.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); Bundle bndlanimation = ActivityOptions .makeCustomAnimation(getApplicationContext(), R.anim.slidefromright, R.anim.slidetoleft) .toBundle(); startActivity(slideactivity, bndlanimation); } }); //onClick listener of the register button: go to Activity_SingUp register.setOnClickListener(new View.OnClickListener() { @Override synchronized public void onClick(View v) { Intent slideactivity = new Intent(Activity_Main.this, Activity_SingUp.class); slideactivity.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); Bundle bndlanimation = ActivityOptions .makeCustomAnimation(getApplicationContext(), R.anim.slidefromright, R.anim.slidetoleft) .toBundle(); startActivity(slideactivity, bndlanimation); } }); //If you close the application without logout, the session will be active //Call a listener of the RequestUser method for Piggate object if (Service_Notify.logout == false) { if (checkInternetConnection()) { loadingDialog = ProgressDialog.show(this, "Singing In", "Wait a few seconds", true); _piggate.RequestUser().setListenerRequest(new Piggate.PiggateCallBack() { //Method onComplete for JSONObject //If the request is completed correctly the user is redirected to Activity_Logged @Override public void onComplete(int statusCode, Header[] headers, String msg, JSONObject data) { loadingDialog.dismiss(); Intent slideactivity = new Intent(Activity_Main.this, Activity_Logged.class); slideactivity.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); Bundle bndlanimation = ActivityOptions.makeCustomAnimation(getApplicationContext(), R.anim.slidefromright, R.anim.slidetoleft).toBundle(); startActivity(slideactivity, bndlanimation); } //Method onError for JSONObject //When we have an error, reload the Piggate object @Override public void onError(int statusCode, Header[] headers, String msg, JSONObject data) { loadingDialog.dismiss(); _piggate.reload(); } //Method onComplete for JSONArray @Override public void onComplete(int statusCode, Header[] headers, String msg, JSONArray data) { //Unused } //Method onError for JSONArray @Override public void onError(int statusCode, Header[] headers, String msg, JSONArray data) { //Unused } }).exec(); } else { networkErrorDialog.show(); } } }
From source file:samples.piggate.com.piggateInfoDemo.Activity_Main.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); _piggate = new Piggate(this, null); //Initialize a Piggate object getSupportActionBar().setTitle("Piggate Info Demo"); networkErrorDialog = new AlertDialog.Builder(this).create(); networkErrorDialog.setTitle("Network error"); networkErrorDialog.setMessage("There is an error with the network connection"); networkErrorDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() { @Override/*from w w w .j a v a 2 s . c o m*/ public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); setContentView(R.layout.activity_main); final Button login = (Button) findViewById(R.id.buttonloginmain); final Button register = (Button) findViewById(R.id.buttonregistermain); //onClick listener of the login button: go to Activity_SingIn login.setOnClickListener(new View.OnClickListener() { @Override synchronized public void onClick(View v) { Intent slideactivity = new Intent(Activity_Main.this, Activity_SingIn.class); slideactivity.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); Bundle bndlanimation = ActivityOptions .makeCustomAnimation(getApplicationContext(), R.anim.slidefromright, R.anim.slidetoleft) .toBundle(); startActivity(slideactivity, bndlanimation); } }); //onClick listener of the register button: go to Activity_SingUp register.setOnClickListener(new View.OnClickListener() { @Override synchronized public void onClick(View v) { Intent slideactivity = new Intent(Activity_Main.this, Activity_SingUp.class); slideactivity.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); Bundle bndlanimation = ActivityOptions .makeCustomAnimation(getApplicationContext(), R.anim.slidefromright, R.anim.slidetoleft) .toBundle(); startActivity(slideactivity, bndlanimation); } }); //If you close the application without logout, the session will be active //Call a listener of the RequestUser method for Piggate object if (Service_Notify.logout == false) { if (checkInternetConnection()) { loadingDialog = ProgressDialog.show(this, "Singing In", "Wait a few seconds", true); _piggate.RequestUser().setListenerRequest(new Piggate.PiggateCallBack() { //Method onComplete for JSONObject //If the request is completed correctly the user is redirected to Activity_Logged @Override public void onComplete(int statusCode, Header[] headers, String msg, JSONObject data) { loadingDialog.dismiss(); Intent slideactivity = new Intent(Activity_Main.this, Activity_Logged.class); slideactivity.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); Bundle bndlanimation = ActivityOptions.makeCustomAnimation(getApplicationContext(), R.anim.slidefromright, R.anim.slidetoleft).toBundle(); startActivity(slideactivity, bndlanimation); } //Method onError for JSONObject //When we have an error, reload the Piggate object @Override public void onError(int statusCode, Header[] headers, String msg, JSONObject data) { loadingDialog.dismiss(); _piggate.reload(); } //Method onComplete for JSONArray @Override public void onComplete(int statusCode, Header[] headers, String msg, JSONArray data) { //Unused } //Method onError for JSONArray @Override public void onError(int statusCode, Header[] headers, String msg, JSONArray data) { //Unused } }).exec(); } else { networkErrorDialog.show(); } } }
From source file:com.android.prachat.gcm.MyGcmPushReceiver.java
/** * Showing notification with text and image * *///from w w w. ja v a 2s . c o m private void showNotificationMessageWithBigImage(Context context, String title, String message, String timeStamp, Intent intent, String imageUrl) { notificationUtils = new NotificationUtils(context); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); notificationUtils.showNotificationMessage(title, message, timeStamp, intent, imageUrl); }
From source file:com.geekandroid.sdk.sample.JPushReceiver.java
@Override public void onReceive(Context context, Intent intent) { Bundle bundle = intent.getExtras();/*from w w w . j a va 2s . co m*/ Log.d(TAG, "[JPushReceiver] onReceive - " + intent.getAction() + ", extras: " + printBundle(bundle)); if (JPushInterface.ACTION_REGISTRATION_ID.equals(intent.getAction())) { String regId = bundle.getString(JPushInterface.EXTRA_REGISTRATION_ID); Log.d(TAG, "[JPushReceiver] Registration Id : " + regId); //send the Registration Id to your server... } else if (JPushInterface.ACTION_MESSAGE_RECEIVED.equals(intent.getAction())) { Log.d(TAG, "[JPushReceiver] ???: " + bundle.getString(JPushInterface.EXTRA_MESSAGE)); processCustomMessage(context, bundle); } else if (JPushInterface.ACTION_NOTIFICATION_RECEIVED.equals(intent.getAction())) { Log.d(TAG, "[JPushReceiver] ??"); int notifactionId = bundle.getInt(JPushInterface.EXTRA_NOTIFICATION_ID); Log.d(TAG, "[JPushReceiver] ??ID: " + notifactionId); } else if (JPushInterface.ACTION_NOTIFICATION_OPENED.equals(intent.getAction())) { Log.d(TAG, "[JPushReceiver] "); JPushImpl.getInstance().clearAllNotifications(); //Activity Intent i = new Intent(context, JPushOpenActivity.class); i.putExtras(bundle); //i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); context.startActivity(i); } else if (JPushInterface.ACTION_RICHPUSH_CALLBACK.equals(intent.getAction())) { Log.d(TAG, "[JPushReceiver] RICH PUSH CALLBACK: " + bundle.getString(JPushInterface.EXTRA_EXTRA)); //? JPushInterface.EXTRA_EXTRA ??Activity .. } else if (JPushInterface.ACTION_CONNECTION_CHANGE.equals(intent.getAction())) { boolean connected = intent.getBooleanExtra(JPushInterface.EXTRA_CONNECTION_CHANGE, false); Log.w(TAG, "[JPushReceiver]" + intent.getAction() + " connected state change to " + connected); } else { Log.d(TAG, "[JPushReceiver] Unhandled intent - " + intent.getAction()); } }
From source file:com.android.mms.ui.ConversationList.java
public static Intent createAddContactIntent(String address) { // address must be a single recipient Intent intent = new Intent(Intent.ACTION_INSERT_OR_EDIT); intent.setType(Contacts.CONTENT_ITEM_TYPE); if (Mms.isEmailAddress(address)) { intent.putExtra(ContactsContract.Intents.Insert.EMAIL, address); } else {//from w w w .j av a2 s .c o m intent.putExtra(ContactsContract.Intents.Insert.PHONE, address); intent.putExtra(ContactsContract.Intents.Insert.PHONE_TYPE, ContactsContract.CommonDataKinds.Phone.TYPE_MOBILE); } intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); return intent; }
From source file:com.googlecode.android_scripting.rpc.MethodDescriptor.java
public static Object buildIntent(JSONObject jsonObject) throws JSONException { Intent intent = new Intent(); if (jsonObject.has("action")) { intent.setAction(jsonObject.getString("action")); }/*from w w w . ja v a2s .com*/ if (jsonObject.has("data") && jsonObject.has("type")) { intent.setDataAndType(Uri.parse(jsonObject.optString("data", null)), jsonObject.optString("type", null)); } else if (jsonObject.has("data")) { intent.setData(Uri.parse(jsonObject.optString("data", null))); } else if (jsonObject.has("type")) { intent.setType(jsonObject.optString("type", null)); } if (jsonObject.has("packagename") && jsonObject.has("classname")) { intent.setClassName(jsonObject.getString("packagename"), jsonObject.getString("classname")); } if (jsonObject.has("flags")) { intent.setFlags(jsonObject.getInt("flags")); } if (!jsonObject.isNull("extras")) { AndroidFacade.putExtrasFromJsonObject(jsonObject.getJSONObject("extras"), intent); } if (!jsonObject.isNull("categories")) { JSONArray categories = jsonObject.getJSONArray("categories"); for (int i = 0; i < categories.length(); i++) { intent.addCategory(categories.getString(i)); } } return intent; }
From source file:com.gigathinking.simpleapplock.ResetUnlockMethod.java
@Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); if (id == android.R.id.home) { finish();/* w w w .j ava2 s . c om*/ Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_HOME); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); return true; } return super.onOptionsItemSelected(item); }
From source file:com.umeng.community.example.CommunityApplication.java
@Override public void onCreate() { super.onCreate(); PlatformConfig.setWeixin("wx96110a1e3af63a39", "c60e3d3ff109a5d17013df272df99199"); //RENREN????? //?//from w ww .j a v a 2s.c o m PlatformConfig.setSinaWeibo("275392174", "d96fb6b323c60a42ed9f74bfab1b4f7a"); PlatformConfig.setQQZone("1104606393", "X4BAsJAVKtkDQ1zQ"); PushAgent.getInstance(this).setDebugMode(true); PushAgent.getInstance(this).setMessageHandler(new UmengMessageHandler() { @Override public void dealWithNotificationMessage(Context arg0, UMessage msg) { // ,???? super.dealWithNotificationMessage(arg0, msg); Log.e("", "### ???"); } }); PushAgent.getInstance(this).setNotificationClickHandler(new UHandler() { @Override public void handleMessage(Context context, UMessage uMessage) { com.umeng.comm.core.utils.Log.d("notifi", "getting message"); try { JSONObject jsonObject = uMessage.getRaw(); String feedid = ""; if (jsonObject != null) { com.umeng.comm.core.utils.Log.d("json", jsonObject.toString()); JSONObject extra = uMessage.getRaw().optJSONObject("extra"); feedid = extra.optString(Constants.FEED_ID); } Class myclass = Class.forName(uMessage.activity); Intent intent = new Intent(context, myclass); Bundle bundle = new Bundle(); bundle.putString(Constants.FEED_ID, feedid); intent.putExtras(bundle); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); } catch (Exception e) { com.umeng.comm.core.utils.Log.d("class", e.getMessage()); } } }); }