List of usage examples for android.content Intent addFlags
public @NonNull Intent addFlags(@Flags int flags)
From source file:foam.zizim.android.BoskoiService.java
private void showNotification(String tickerText) { // This is what should be launched if the user selects our notification. Intent baseIntent = new Intent(this, IncidentsTab.class); baseIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); PendingIntent contentIntent = PendingIntent.getActivity(this, 0, baseIntent, 0); // choose the ticker text newBoskoiReportNotification = new Notification(R.drawable.favicon, tickerText, System.currentTimeMillis()); newBoskoiReportNotification.contentIntent = contentIntent; newBoskoiReportNotification.flags = Notification.FLAG_AUTO_CANCEL; newBoskoiReportNotification.defaults = Notification.DEFAULT_ALL; newBoskoiReportNotification.setLatestEventInfo(this, TAG, tickerText, contentIntent); if (ringtone) { // set the ringer Uri ringURI = Uri.fromFile(new File("/system/media/audio/ringtones/ringer.mp3")); newBoskoiReportNotification.sound = ringURI; }// w w w .j av a 2 s. c o m if (vibrate) { double vibrateLength = 100 * Math.exp(0.53 * 20); long[] vibrate = new long[] { 100, 100, (long) vibrateLength }; newBoskoiReportNotification.vibrate = vibrate; if (flashLed) { int color = Color.BLUE; newBoskoiReportNotification.ledARGB = color; } newBoskoiReportNotification.ledOffMS = (int) vibrateLength; newBoskoiReportNotification.ledOnMS = (int) vibrateLength; newBoskoiReportNotification.flags = newBoskoiReportNotification.flags | Notification.FLAG_SHOW_LIGHTS; } mNotificationManager.notify(NOTIFICATION_ID, newBoskoiReportNotification); }
From source file:au.id.micolous.frogjump.Util.java
public static void navigateTo(int latE6, int lngE6, MainActivity.NavigationMode navigationMode, Context context) {/*w ww . ja v a2 s .co m*/ // Lets make that a decimal again String geoloc = String.format("%1$d.%2$06d,%3$d.%4$06d", latE6 / 1000000, Math.abs(latE6 % 1000000), lngE6 / 1000000, Math.abs(lngE6 % 1000000)); Intent intent = null; if (navigationMode == MainActivity.NavigationMode.CROW_FLIES || navigationMode == MainActivity.NavigationMode.SHOW_MAP) { geoloc = "geo:" + geoloc + "?q=" + geoloc; Uri geouri = Uri.parse(geoloc); intent = new Intent(Intent.ACTION_VIEW, geouri); if (navigationMode == MainActivity.NavigationMode.CROW_FLIES) { intent.setPackage(GPS_STATUS); } } else if (navigationMode != MainActivity.NavigationMode.OFF) { geoloc = "google.navigation:q=" + geoloc; switch (navigationMode) { // https://developers.google.com/maps/documentation/directions/intro#Restrictions // The intent service supports this parameter too, but it is not documented. case DRIVING_AVOID_TOLLS: geoloc += "&avoid=tolls"; case DRIVING: geoloc += "&mode=d"; break; case CYCLING: geoloc += "&mode=b"; break; case WALKING: geoloc += "&mode=w"; break; } // Launch Google Maps Uri geouri = Uri.parse(geoloc); intent = new Intent(Intent.ACTION_VIEW, geouri); intent.setPackage(GOOGLE_MAPS); } if (intent != null) { intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); } }
From source file:net.evecom.androidecssp.base.BaseWebActivity.java
/** * //from w w w. j a v a 2 s .c o m * * * @author Mars zhang * @created 2015-11-25 2:11:17 * @param file * @return */ public Intent getFileIntent(File file) { // Uri uri = Uri.parse("http://m.ql18.com.cn/hpf10/1.pdf"); Uri uri = Uri.fromFile(file); String type = getMIMEType(file); Log.i("tag", "type=" + type); Intent intent = new Intent("android.intent.action.VIEW"); intent.addCategory("android.intent.category.DEFAULT"); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setDataAndType(uri, type); return intent; }
From source file:com.example.pyrkesa.shwc.LoginActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main_log);/*from www . jav a2s . com*/ final ModelFactory model = (ModelFactory) ModelFactory.getContext(); UserAuthenticate = model.UserAuthenticate; //For settings option-- put it in the first acticity on the onCreate function if (getIntent().getBooleanExtra("Exit me", false)) { finish(); } if (LoginActivity.UserAuthenticate) { Intent homepage = new Intent(getApplicationContext(), MainActivity.class); homepage.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(homepage); finish(); } final Handler searchipHandler = new Handler() { @Override public void handleMessage(Message msg) { String shwcipadress = msg.getData().getString("ip"); if (shwcipadress != null) { if (LoginActivity.UserAuthenticate == false) { LoginActivity.shwcserverFound = true; LoginActivity.url_all_box = "http://" + shwcipadress + "/SHWCDataManagement/Box/get_all_box.php"; LoginActivity.url_authenticate = "http://" + shwcipadress + "/SHWCDataManagement/Users/authenticate.php"; LoginActivity.url_authenticateByDevice = "http://" + shwcipadress + "/SHWCDataManagement/Users/authenticateByDevice.php"; Log.d("SHWCServer", "IP=" + shwcipadress); String android_id = Secure.getString(getContentResolver(), Secure.ANDROID_ID); Log.d("Android id :", android_id); ArrayList<String> Logs1 = new ArrayList<String>(); Logs1.add(url_authenticateByDevice); Logs1.add(android_id); Logs1.add(url_all_box); new AuthenticateUserByDevice().execute(Logs1); } } } }; // Run the ServiceNSD to find the shwcserver //final FindServicesNSD zeroconf=new FindServicesNSD((NsdManager)getSystemService(NSD_SERVICE), "_http._tcp",searchipHandler); //zeroconf.run(); // LoginActivity.x=zeroconf; // simulation dcouverte serveur shwc LoginActivity.shwcserverFound = true; model.api_url = "http://" + "10.0.1.5" + "/SHWCDataManagement/"; LoginActivity.url_all_box = model.api_url + "Box/get_all_box.php"; LoginActivity.url_authenticate = model.api_url + "Users/authenticate.php"; LoginActivity.url_authenticateByDevice = model.api_url + "Users/authenticateByDevice.php"; String android_id = Secure.getString(getContentResolver(), Secure.ANDROID_ID); Log.d("Android id :", android_id); ArrayList<String> Logs1 = new ArrayList<String>(); Logs1.add(url_authenticateByDevice); Logs1.add(android_id); Logs1.add(url_all_box); if (getIntent().hasExtra("logout")) { new LoadAllBoxes().execute(url_all_box); } else { new AuthenticateUserByDevice().execute(Logs1); } /// end simulation LogInButton = ((ImageButton) this.findViewById(R.id.LogInButton)); // Get login and password from EditText final EditText login = ((EditText) this.findViewById(R.id.login)); final EditText password = ((EditText) this.findViewById(R.id.password)); final Spinner box_choice = ((Spinner) this.findViewById(R.id.box_choice)); LogInButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (LoginActivity.shwcserverFound) { String pass = password.getText().toString(); String log = login.getText().toString(); String box = box_choice.getSelectedItem().toString(); String android_id1 = Secure.getString(getContentResolver(), Secure.ANDROID_ID); ArrayList<String> Logs = new ArrayList<String>(); Logs.add(log); Logs.add(pass); Logs.add(url_authenticate); Logs.add(android_id1); Logs.add(box); new AuthenticateUser().execute(Logs); } else { Toast.makeText(LoginActivity.this, "Systme SHWC indisponible !", Toast.LENGTH_LONG).show(); } } }); // on seleting single product // launching Edit Product Screen }
From source file:se.droidgiro.scanner.CaptureActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.about: { Intent intent = new Intent(this, About.class); startActivity(intent);/* w ww .j av a2 s .c o m*/ break; } case R.id.settings: { Intent intent = new Intent(Intent.ACTION_VIEW); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); intent.setClassName(this, PreferencesActivity.class.getName()); startActivity(intent); break; } } return super.onOptionsItemSelected(item); }
From source file:com.medisa.myspacecal.Range.java
private void invokeActivity(String title, int resId) { Intent intent = new Intent(this, MainActivity.class); intent.putExtra(EXTRA_TITLE, title); intent.putExtra(EXTRA_RESOURCE_ID, resId); intent.putExtra(EXTRA_MODE, sideNavigationView.getMode() == Mode.LEFT ? 0 : 1); // all of the other activities on top of it will be closed and this // Intent will be delivered to the (now on top) old activity as a // new Intent. intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent);// w w w . j a v a 2 s . c om // no animation of transition overridePendingTransition(0, 0); }
From source file:notused.Login.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.login);/* w w w . ja v a2s .co m*/ txtEmail = (TextView) findViewById(R.id.email); txtPassword = (TextView) findViewById(R.id.password); btnLogin = (Button) findViewById(R.id.login); ckRememberMe = (CheckBox) findViewById(R.id.checkbox); txtForgotPassword = (TextView) findViewById(R.id.forgotPassword); txtSignUp = (TextView) findViewById(R.id.signUp); validator = new Validator(); config = new Config(Login.this); dbAdapter = new UserDBAdapter(this); baseUrl = "http://lawpavilionstore.com/android/login"; dbAdapter.open(DB_NAME); //TODO: remove drop table query dbAdapter.executeQuery("DROP TABLE IF EXISTS" + dbAdapter.TABLE_NAME + ";"); //dbAdapter.createUserTable(); Cursor cursor = dbAdapter.fetch("SELECT * from " + dbAdapter.TABLE_NAME); if (cursor != null) { //new user if (cursor.getCount() == 1) { String loggedOut = cursor.getString(cursor.getColumnIndex(dbAdapter.LOG_OUT)); if (loggedOut.equalsIgnoreCase("0")) { //User not looged out..continue String token = cursor.getString(cursor.getColumnIndex(dbAdapter.TOKEN)); Toast.makeText(Login.this, "Existing", Toast.LENGTH_SHORT).show(); Login.this.finish(); String set_up_status = cursor.getString(cursor.getColumnIndex(dbAdapter.SET_UP_STATUS)); if (set_up_status.equalsIgnoreCase("pending")) { Intent intent = new Intent(Login.this, Module.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); } else { Intent intent = new Intent(Login.this, Dashboard.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); } } else { //user has been forced to login.. SIGN_IN_TYPE = LOGGED_OUT_USER_TYPE; } } else { //New user account.. SIGN_IN_TYPE = NEW_USER_TYPE; } } else { Toast.makeText(Login.this, "DB error", Toast.LENGTH_SHORT).show(); //Do something here } dbAdapter.close(); btnLogin.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { _email = txtEmail.getText().toString().trim(); _password = txtPassword.getText().toString().trim(); boolean isFieldSet = true; if (!validator.isValidEmail(_email)) { txtEmail.setError(Validator.emailErrorMessage); isFieldSet = false; } if (validator.isEmpty(_password)) { txtPassword.setError(Validator.defaultErrorMessage); isFieldSet = false; } Toast.makeText(Login.this, "Ready for Async Task", Toast.LENGTH_SHORT).show(); if (isFieldSet) { if (config.isConnectingToInternet()) { AsyncLogin asyncLogin = new AsyncLogin(); asyncLogin.execute(); } else { AlertDialog.Builder builder = new AlertDialog.Builder(Login.this); builder.setTitle("Error"); builder.setMessage("Oops! Something went wrong!\n\nplease check your internet connection") .setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }).setPositiveButton("Retry", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { AsyncLogin asyncLogin = new AsyncLogin(); asyncLogin.execute(); } }); AlertDialog dialog = builder.create(); dialog.show(); } } else { return; } } }); txtForgotPassword.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(Login.this, ForgotPassword.class); startActivity(intent); } }); txtSignUp.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(Login.this, SignUp.class); startActivity(intent); } }); }
From source file:com.fabernovel.alertevoirie.MyIncidentsActivityMap.java
/** Called when the activity is first created. */ @Override//www. ja v a2s . co m public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().requestFeature(Window.FEATURE_LEFT_ICON); setContentView(R.layout.layout_report_map); getWindow().setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, R.drawable.icon_mes_rapports); map = (MapView) findViewById(R.id.MapView_mymap); map.setBuiltInZoomControls(true); tabs = (RadioGroup) findViewById(R.id.RadioGroup_tabs_map); // mOverlay = new SimpleItemizedOverlay(getResources().getDrawable(R.drawable.map_cursor), this, map); map.getOverlays().add(mOverlay); map.setSatellite(false); tbmap = (ToggleButton) findViewById(R.id.ToggleButton_Map); tbmap.setChecked(true); tbmap.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (!isChecked) { tbmap.setChecked(true); Intent i = new Intent(MyIncidentsActivityMap.this, MyIncidentsActivity.class); i.putExtra("tab1", title[0]); i.putExtra("tab2", title[1]); i.putExtra("tab3", title[2]); i.putExtra("datas", data.toString()); i.putExtra("tab", checked); i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP).addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); startActivity(i); } } }); if (getIntent().getExtras().getInt("tab") != 0) { title[0] = getIntent().getExtras().getString("tab1"); title[1] = getIntent().getExtras().getString("tab2"); title[2] = getIntent().getExtras().getString("tab3"); ((TextView) tabs.getChildAt(0)).setText(title[0]); if (title[0].startsWith("0")) ((TextView) tabs.getChildAt(0)).setEnabled(false); ((TextView) tabs.getChildAt(1)).setText(title[1]); if (title[1].startsWith("0")) ((TextView) tabs.getChildAt(1)).setEnabled(false); ((TextView) tabs.getChildAt(2)).setText(title[2]); if (title[2].startsWith("0")) ((TextView) tabs.getChildAt(2)).setEnabled(false); checked = getIntent().getExtras().getInt("tab"); try { data = new JSONObject(getIntent().getExtras().getString("datas")); } catch (JSONException e) { Log.e(Constants.PROJECT_TAG, "JSon data exception", e); } // setMapForTab(gettabIndex(tabs.getCheckedRadioButtonId())); } else { // launch request try { AVService.getInstance(this) .postJSON(new JSONArray().put(new JSONObject() .put(JsonData.PARAM_REQUEST, JsonData.VALUE_REQUEST_GET_MY_INCIDENTS) .put(JsonData.PARAM_UDID, Utils.getUdid(this))), this); showDialog(DIALOG_PROGRESS); } catch (JSONException e) { Log.e(Constants.PROJECT_TAG, "error launching My Incidents", e); } } // get view references tabs.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { Log.d(Constants.PROJECT_TAG, "checked : " + checkedId); checked = checkedId; setMapForTab(gettabIndex(checkedId)); } }); tabs.check(getId()); if (checked == R.id.Tab_Map_ongoing) { setMapForTab(gettabIndex(checked)); } }
From source file:com.aniruddhc.acemusic.player.AsyncTasks.AsyncAutoGetAlbumArtTask.java
@Override protected void onPostExecute(Void arg0) { Intent intent = new Intent(mContext, AutoFetchAlbumArtService.class); mContext.stopService(intent);// w w w. j a va2 s. c o m if (pd.isShowing() && DIALOG_VISIBLE == true) { pd.dismiss(); } //Dismiss the notification. AutoFetchAlbumArtService.builder .setTicker(mContext.getResources().getString(R.string.done_downloading_art)); AutoFetchAlbumArtService.builder .setContentTitle(mContext.getResources().getString(R.string.done_downloading_art)); AutoFetchAlbumArtService.builder.setSmallIcon(R.drawable.notif_icon); AutoFetchAlbumArtService.builder.setContentInfo(null); AutoFetchAlbumArtService.builder.setContentText(null); AutoFetchAlbumArtService.builder.setProgress(0, 0, false); AutoFetchAlbumArtService.notification = AutoFetchAlbumArtService.builder.build(); AutoFetchAlbumArtService.notification.flags = Notification.FLAG_AUTO_CANCEL; NotificationManager notifyManager = (NotificationManager) mContext .getSystemService(Context.NOTIFICATION_SERVICE); notifyManager.notify(AutoFetchAlbumArtService.NOTIFICATION_ID, AutoFetchAlbumArtService.notification); Toast.makeText(mContext, R.string.done_downloading_art, Toast.LENGTH_LONG).show(); //Rescan for album art. //Seting the "RESCAN_ALBUM_ART" flag to true will force MainActivity to rescan the folders. sharedPreferences.edit().putBoolean("RESCAN_ALBUM_ART", true).commit(); //Restart the app. final Intent i = mActivity.getBaseContext().getPackageManager() .getLaunchIntentForPackage(mActivity.getBaseContext().getPackageName()); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); mActivity.startActivity(i); mActivity.finish(); }
From source file:org.openhab.habdroid.ui.OpenHABRoomSettingActivity.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { Log.i(TAG, "onActivityResult " + String.valueOf(requestCode) + " " + String.valueOf(resultCode)); if (resultCode == -1) { // Right now only PreferencesActivity returns -1 // Restart app after preferences Log.i(TAG, "Restarting"); // Get launch intent for application Intent restartIntent = getBaseContext().getPackageManager() .getLaunchIntentForPackage(getBaseContext().getPackageName()); restartIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); // Finish current activity finish();//ww w . ja va 2 s . c o m // Start launch activity startActivity(restartIntent); } }