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:samples.piggate.com.piggateCompleteExample.Activity_Logged.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); _piggate = new Piggate(this, null); //Initialize the Piggate object setContentView(R.layout.activity_logged); getSupportActionBar().setTitle(PiggateUser.getEmail()); startService(new Intent(getApplicationContext(), Service_Notify.class)); //Start the service //Initialize and set all the left navigation drawer fields mDrawer = new Drawer().withActivity(this).withTranslucentStatusBar(false).withHeader(R.layout.drawerheader) .addDrawerItems( /* Add drawer items with this method */) .withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() { @Override//from w w w .j av a2s. co m public void onItemClick(AdapterView<?> parent, View view, int position, long id, IDrawerItem drawerItem) { // Open the exchange activity for the selected item Intent slideactivity = new Intent(Activity_Logged.this, Activity_Exchange.class); slideactivity.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); //Send the current offer information to the exchange activity slideactivity.putExtra("offerName", exchangeOfferList.get(position).getName().toString()); slideactivity.putExtra("offerDescription", exchangeOfferList.get(position).getDescription().toString()); slideactivity.putExtra("offerImgURL", exchangeOfferList.get(position).getImgURL().toString()); slideactivity.putExtra("exchangeID", exchangeOfferList.get(position).getExchangeID().toString()); Bundle bndlanimation = ActivityOptions.makeCustomAnimation(Activity_Logged.this, R.anim.slidefromright, R.anim.slidetoleft).toBundle(); startActivity(slideactivity, bndlanimation); } }).withSliderBackgroundColor(Color.parseColor("#FFFFFF")).withSelectedItem(-1).build(); //Initialize recycler view mRecyclerView = (RecyclerView) findViewById(R.id.my_recycler_view); mRecyclerView.setHasFixedSize(true); mRecyclerView.setLayoutManager(new LinearLayoutManager(Activity_Logged.this)); mRecyclerView.setItemAnimator(new DefaultItemAnimator()); newBeaconsLayout = (LinearLayout) findViewById(R.id.newBeaconsLayout); //Initialize swipe layout mSwipeLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_container); mSwipeLayout.setOnRefreshListener(this); errorDialog = new AlertDialog.Builder(this).create(); errorDialog.setTitle("Logout error"); errorDialog.setMessage("There is an error with the logout"); errorDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); successPaymentDialog = new AlertDialog.Builder(this).create(); successPaymentDialog.setTitle("Successful payment"); successPaymentDialog.setMessage("Now you can exchange your purchased product"); successPaymentDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); errorBuyDialog = new AlertDialog.Builder(this).create(); errorBuyDialog.setTitle("Payment failed"); errorBuyDialog.setMessage("There is an error with your payment"); errorBuyDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); successExchangeDialog = new AlertDialog.Builder(this).create(); successExchangeDialog.setTitle("Offer successfully exchanged"); successExchangeDialog.setMessage("The offer has been purchased and exchanged"); successExchangeDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); errorExchangeDialog = new AlertDialog.Builder(this).create(); errorExchangeDialog.setTitle("Exchange error"); errorExchangeDialog.setMessage("There is an error with the exchange"); errorExchangeDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); 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 public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); fadeIn = AnimationUtils.loadAnimation(Activity_Logged.this, R.anim.fadein); fadeOut = AnimationUtils.loadAnimation(Activity_Logged.this, R.anim.fadeout); //Check if the bluetooth is switched on BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); if (!mBluetoothAdapter.isEnabled()) { Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT); } if (getIntent().hasExtra("payment")) { if (getIntent().getExtras().getBoolean("payment") == true) { successPaymentDialog.show(); //Show success payment dialog mDrawer.openDrawer(); //Open the left panel } else { errorBuyDialog.show(); //Show payment error dialog } } else if (getIntent().hasExtra("exchanged")) { if (getIntent().getExtras().getBoolean("exchanged") == true) { successExchangeDialog.show(); //Show exchange success dialog } else { errorExchangeDialog.show(); //Show exchange error dialog } } }
From source file:app.androidhive.info.realm.GCM.GcmIntentService.java
private void sendNotification(String title, String msg, String link) { mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE); /* Intent intent = new Intent(this, MainActivity.class); intent.putExtra("phone", link);//from w w w . j av a 2 s . c o m PendingIntent contentIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);*/ Phone = link; // getData(link); Intent dialogIntent = new Intent(getBaseContext(), MainActivity.class); dialogIntent.putExtra("Phone", link); dialogIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); getApplication().startActivity(dialogIntent); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setLargeIcon(BitmapFactory.decodeResource(getBaseContext().getResources(), R.mipmap.ic_launcher)) .setSmallIcon(R.mipmap.ic_launcher).setContentTitle(link).setAutoCancel(true) .setStyle(new NotificationCompat.BigTextStyle().bigText(msg)).setContentText(msg); // Set the notification vibrate option if (preferences.getBoolean("notifications_new_message_vibrate", true)) { mBuilder.setVibrate(new long[] { 1000, 1000, 1000, 1000, 1000 }); } // Set the notification ringtone if (preferences.getString("notifications_new_message_ringtone", null) != null) { mBuilder.setSound(Uri.parse(preferences.getString("notifications_new_message_ringtone", null))); } else { Uri alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); mBuilder.setSound(alarmSound); } // Show only if the notification are enabled if (preferences.getBoolean("notifications_new_message", true)) { // mBuilder.setContentIntent(contentIntent); mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build()); } }
From source file:info.snowhow.plugin.RecorderService.java
private void showNoGPSAlert() { Log.i(LOG_TAG, "No GPS available --- show Dialog"); AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); alertDialogBuilder.setMessage("GPS is disabled on your device. Would you like to enable it?") .setCancelable(false).setPositiveButton("GPS Settings", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Intent callGPSSettingIntent = new Intent( android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS); callGPSSettingIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(callGPSSettingIntent); }/*from w w w. j a v a2 s. com*/ }); alertDialogBuilder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { stopRecording(); dialog.cancel(); } }); AlertDialog alert = alertDialogBuilder.create(); alert.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); alert.show(); }
From source file:fr.cph.chicago.core.activity.BusBoundActivity.java
@Override public final void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); App.checkBusData(this); if (!this.isFinishing()) { setContentView(R.layout.activity_bus_bound); ButterKnife.bind(this); if (busRouteId == null || busRouteName == null || bound == null || boundTitle == null) { final Bundle extras = getIntent().getExtras(); busRouteId = extras.getString(bundleBusRouteId); busRouteName = extras.getString(bundleBusRouteName); bound = extras.getString(bundleBusBound); boundTitle = extras.getString(bundleBusBoundTitle); }/*from ww w.j a v a2s .c o m*/ busBoundAdapter = new BusBoundAdapter(); setListAdapter(busBoundAdapter); getListView().setOnItemClickListener((adapterView, view, position, id) -> { final BusStop busStop = (BusStop) busBoundAdapter.getItem(position); final Intent intent = new Intent(getApplicationContext(), BusActivity.class); final Bundle extras = new Bundle(); extras.putInt(bundleBusStopId, busStop.getId()); extras.putString(bundleBusStopName, busStop.getName()); extras.putString(bundleBusRouteId, busRouteId); extras.putString(bundleBusRouteName, busRouteName); extras.putString(bundleBusBound, bound); extras.putString(bundleBusBoundTitle, boundTitle); extras.putDouble(bundleBusLatitude, busStop.getPosition().getLatitude()); extras.putDouble(bundleBusLongitude, busStop.getPosition().getLongitude()); intent.putExtras(extras); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); }); filter.addTextChangedListener(new TextWatcher() { private List<BusStop> busStopsFiltered; @Override public void beforeTextChanged(final CharSequence s, final int start, final int count, final int after) { busStopsFiltered = new ArrayList<>(); } @Override public void onTextChanged(final CharSequence s, final int start, final int before, final int count) { if (busStops != null) { Stream.of(busStops).filter(busStop -> StringUtils.containsIgnoreCase(busStop.getName(), s)) .forEach(busStopsFiltered::add); } } @Override public void afterTextChanged(final Editable s) { busBoundAdapter.update(busStopsFiltered); busBoundAdapter.notifyDataSetChanged(); } }); Util.setWindowsColor(this, toolbar, TrainLine.NA); toolbar.setTitle(busRouteId + " - " + boundTitle); toolbar.setNavigationIcon(arrowBackWhite); toolbar.setOnClickListener(v -> finish()); ObservableUtil.createBusStopBoundObservable(getApplicationContext(), busRouteId, bound) .subscribe(onNext -> { busStops = onNext; busBoundAdapter.update(onNext); busBoundAdapter.notifyDataSetChanged(); }, onError -> { Log.e(TAG, onError.getMessage(), onError); Util.showOopsSomethingWentWrong(getListView()); }); Util.trackAction(this, R.string.analytics_category_req, R.string.analytics_action_get_bus, BUSES_STOP_URL, 0); // Preventing keyboard from moving background when showing up getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); } }
From source file:com.doplgangr.secrecy.Util.java
public static void openURI(String uri) { Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(uri));// ww w . ja v a 2 s . c o m i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); CustomApp.context.startActivity(i); }
From source file:samples.piggate.com.piggateCompleteExample.Activity_SingIn.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); _piggate = new Piggate(this, null); //Initialize the Piggate object getSupportActionBar().setTitle("Login"); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayShowHomeEnabled(true); setContentView(R.layout.activity_login); //EditTexts for user email and password editEmail = (EditText) findViewById(R.id.editText1); editPass = (EditText) findViewById(R.id.editText2); Button login = (Button) findViewById(R.id.buttonlogin); errorDialog = new AlertDialog.Builder(this).create(); errorDialog.setTitle("Login error"); errorDialog.setMessage("There is an error with the login"); errorDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() { @Override/*from w ww . j a v a 2 s .c om*/ public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); 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 public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); //OnClick listener for the login button //Handles the login request to the server with the email and password fields login.setOnClickListener(new View.OnClickListener() { @Override synchronized public void onClick(View v) { String email = editEmail.getText().toString(); String pass = editPass.getText().toString(); //If the internet connection is working if (checkInternetConnection() == true) { if (editEmail.getText().toString().equals("") || editPass.getText().toString().equals("")) { if (editEmail.getText().toString().equals("")) editEmail.setError("Enter your email"); if (editPass.getText().toString().equals("")) editPass.setError("Enter your password"); } else { loadingDialog = ProgressDialog.show(v.getContext(), "Singing In", "Wait a few seconds", true); RequestParams params = new RequestParams(); params.put("email", email); params.put("password", pass); //Request of the Piggate object. Handles the login into the application with the user email and password _piggate.RequestOpenSession(params).setListenerRequest(new Piggate.PiggateCallBack() { //Method onComplete for JSONObject //When the request is correct start Activity_Logged activity @Override public void onComplete(int statusCode, Header[] headers, String msg, JSONObject data) { loadingDialog.dismiss(); Intent slideactivity = new Intent(Activity_SingIn.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 //If there's an error with the request displays the error message to the user @Override public void onError(int statusCode, Header[] headers, String msg, JSONObject data) { loadingDialog.dismiss(); runOnUiThread(new Runnable() { @Override public void run() { errorDialog.show(); } }); } //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 { //If the internet connection is not working networkErrorDialog.show(); } } }); }
From source file:samples.piggate.com.piggateCompleteExample.Activity_Exchange.java
public void goBackActivity(boolean exchanged) { //Go back to the offer list passing the offer attributes (to exchange) Intent slideactivity = new Intent(Activity_Exchange.this, Activity_Logged.class); slideactivity.putExtra("exchanged", exchanged); slideactivity.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); Bundle bndlanimation = ActivityOptions .makeCustomAnimation(getApplicationContext(), R.anim.slidefromleft, R.anim.slidetoright).toBundle(); startActivity(slideactivity, bndlanimation); }
From source file:com.gigathinking.simpleapplock.ResetUnlockMethod.java
@Override public void onBackPressed() { finish();//from ww w . ja v 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:fr.cph.chicago.activity.BusBoundActivity.java
@Override public final void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); ChicagoTracker.checkBusData(this); if (!this.isFinishing()) { setContentView(R.layout.activity_bus_bound); if (mBusRouteId == null && mBusRouteName == null && mBound == null) { mBusRouteId = getIntent().getExtras().getString("busRouteId"); mBusRouteName = getIntent().getExtras().getString("busRouteName"); mBound = getIntent().getExtras().getString("bound"); }//w ww.j a va 2 s . c o m mAdapter = new BusBoundAdapter(mBusRouteId); setListAdapter(mAdapter); getListView().setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) { BusStop busStop = (BusStop) mAdapter.getItem(position); Intent intent = new Intent(ChicagoTracker.getAppContext(), BusActivity.class); Bundle extras = new Bundle(); extras.putInt("busStopId", busStop.getId()); extras.putString("busStopName", busStop.getName()); extras.putString("busRouteId", mBusRouteId); extras.putString("busRouteName", mBusRouteName); extras.putString("bound", mBound); extras.putDouble("latitude", busStop.getPosition().getLatitude()); extras.putDouble("longitude", busStop.getPosition().getLongitude()); intent.putExtras(extras); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); overridePendingTransition(R.anim.slide_in, R.anim.slide_out); } }); EditText filter = (EditText) findViewById(R.id.bus_filter); filter.addTextChangedListener(new TextWatcher() { List<BusStop> busStopsFiltered; @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { busStopsFiltered = new ArrayList<BusStop>(); } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { for (BusStop busStop : mBusStops) { if (StringUtils.containsIgnoreCase(busStop.getName(), s)) { this.busStopsFiltered.add(busStop); } } } @Override public void afterTextChanged(Editable s) { mAdapter.update(busStopsFiltered); mAdapter.notifyDataSetChanged(); } }); getActionBar().setDisplayHomeAsUpEnabled(true); new BusBoundAsyncTask().execute(); // Preventing keyboard from moving background when showing up getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); } }
From source file:samples.piggate.com.piggateCompleteExample.Activity_SingUp.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); _piggate = new Piggate(this, null); //Initialize the Piggate object getSupportActionBar().setTitle("Register"); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayShowHomeEnabled(true); setContentView(R.layout.activity_register); //EditTexts for user email and password editEmail = (EditText) findViewById(R.id.editText1); editPass = (EditText) findViewById(R.id.editText2); Button register = (Button) findViewById(R.id.buttonregister); errorDialog = new AlertDialog.Builder(this).create(); errorDialog.setTitle("Login error"); errorDialog.setMessage("There is an error with the login"); errorDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() { @Override//ww w. ja v a 2 s .c o m public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); 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 public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); //OnClick listener for the login button //Handles the register request to the server with the email and password fields //and the login request if the fields are correct register.setOnClickListener(new View.OnClickListener() { @Override synchronized public void onClick(View v) { String email = editEmail.getText().toString(); String pass = editPass.getText().toString(); //If the internet connection is working if (checkInternetConnection() == true) { if (editEmail.getText().toString().equals("") || editPass.getText().toString().equals("")) { if (editEmail.getText().toString().equals("")) editEmail.setError("Enter your email"); if (editPass.getText().toString().equals("")) editPass.setError("Enter your password"); } else { loadingDialog = ProgressDialog.show(v.getContext(), "Singing Up", "Wait a few seconds", true); RequestParams params = new RequestParams(); params.put("email", email); params.put("password", pass); //Request of the Piggate object. Handles the register into the application // and the login with the user email and password _piggate.RequestNewUser(params).setListenerRequest(new Piggate.PiggateCallBack() { //Method onComplete for JSONObject //When the request is correct start Activity_Logged activity @Override public void onComplete(int statusCode, Header[] headers, String msg, JSONObject data) { loadingDialog.dismiss(); Intent slideactivity = new Intent(Activity_SingUp.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 //If there's an error with the request displays the error message to the user @Override public void onError(int statusCode, Header[] headers, String msg, JSONObject data) { loadingDialog.dismiss(); runOnUiThread(new Runnable() { @Override public void run() { errorDialog.show(); } }); } //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 { //If the internet connection is not working networkErrorDialog.show(); } } }); }