List of usage examples for android.content Intent setFlags
public @NonNull Intent setFlags(@Flags int flags)
From source file:com.dycody.android.idealnote.async.DataBackupIntentService.java
/** * Creation of notification on operations completed *///from w w w.ja va2 s.c o m private void createNotification(Intent intent, Context mContext, String title, String message, File backupDir) { // The behavior differs depending on intent action Intent intentLaunch; if (DataBackupIntentService.ACTION_DATA_IMPORT.equals(intent.getAction()) || DataBackupIntentService.ACTION_DATA_IMPORT_SPRINGPAD.equals(intent.getAction())) { intentLaunch = new Intent(mContext, MainActivity.class); intentLaunch.setAction(Constants.ACTION_RESTART_APP); } else { intentLaunch = new Intent(); } // Add this bundle to the intent intentLaunch.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intentLaunch.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // Creates the PendingIntent PendingIntent notifyIntent = PendingIntent.getActivity(mContext, 0, intentLaunch, PendingIntent.FLAG_UPDATE_CURRENT); NotificationsHelper mNotificationsHelper = new NotificationsHelper(mContext); mNotificationsHelper .createNotification(com.dycody.android.idealnote.R.drawable.ic_content_save_white_24dp, title, notifyIntent) .setMessage(message).setRingtone(prefs.getString("settings_notification_ringtone", null)) .setLedActive(); if (prefs.getBoolean("settings_notification_vibration", true)) mNotificationsHelper.setVibration(); mNotificationsHelper.show(); }
From source file:com.polyvi.xface.extension.XAppExt.java
/** * ?componen/*from w w w . ja v a2 s . c o m*/ * * @param componenName * ??componen?? return true??,false? */ private boolean startSystemComponent(int componentCode) { SysComponent componentName = SysComponent.UNKNOWN; try { componentName = SysComponent.values()[componentCode]; } catch (ArrayIndexOutOfBoundsException e) { XLog.d(CLASS_NAME, "unkown component name!", e); return false; } Intent intent = null; boolean success = false; switch (componentName) { case VPN_CONFIG: intent = new Intent("android.net.vpn.SETTINGS"); break; case WIRELESS_CONFIG: intent = new Intent(Settings.ACTION_WIRELESS_SETTINGS); break; case GPS_CONFIG: intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); break; default: XLog.d(CLASS_NAME, "unkown component name!"); break; } if (null != intent) { intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); getContext().startActivity(intent); success = true; } return success; }
From source file:com.tt.jobtracker.MainActivity.java
public void onTaskSelected(TaskViewModel task) { Shared.hideMenu = String.valueOf(task.IsDone); if (task.IsMeasurement) { //call measurement fragment Shared.MeasurementTaskID = task.ID; Intent intent = new Intent(MainActivity.this, TakeMeasurementList.class); DatabaseHelper dbHelper = new DatabaseHelper(this); Shared.SelectedTask = dbHelper.getTaskInfo(String.valueOf(task.ID)); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.putExtra("TaskID", String.valueOf(task.ID)); intent.putExtra("ShopID", String.valueOf(task.ShopID)); intent.putExtra("ShopName", String.valueOf(task.ShopName)); intent.putExtra("ShopAddress", String.valueOf(task.ShopAddress)); intent.putExtra("IsDone", String.valueOf(task.IsDone)); getApplicationContext().startActivity(intent); // Intent myIntent = new Intent(MainActivity.this, TakeMeasurement.class); //myIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // myIntent.putExtra("PhotoID",taskLineItemViewModel.PhotoID); // getApplicationContext().startActivity(myIntent); // finish(); }/*from www .ja va 2 s. c o m*/ else { //call execution fragment Fragment fragment = new TaskDetailFragment(); if (fragment != null) { Bundle args = new Bundle(); args.putSerializable("Task", task); fragment.setArguments(args); FragmentManager fragmentManager = getSupportFragmentManager(); fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).addToBackStack("tasklist") .commit(); } } }
From source file:com.cbtec.eliademy.EliademyLms.java
/** * Executes the request./*ww w. ja va 2 s .c o m*/ * * This method is called from the WebView thread. To do a non-trivial amount * of work, use: cordova.getThreadPool().execute(runnable); * * To run on the UI thread, use: * cordova.getActivity().runOnUiThread(runnable); * * @param action * The action to execute. * @param rawArgs * The exec() arguments in JSON form. * @param callbackContext * The callback context used when calling back into JavaScript. * @return Whether the action was valid. * @throws JSONException */ @Override public boolean execute(String action, JSONArray data, final CallbackContext callbackContext) throws JSONException { Log.i("HLMS", action); if ((action.compareTo("openfilesrv") == 0)) { try { Uri fileuri = Uri.parse(data.getString(0)); Intent intent = new Intent(Intent.ACTION_VIEW); String mimeextn = android.webkit.MimeTypeMap.getFileExtensionFromUrl(data.getString(0)); if (mimeextn.isEmpty()) { mimeextn = data.getString(0).substring(data.getString(0).indexOf(".") + 1); ; } String mimetype = android.webkit.MimeTypeMap.getSingleton().getMimeTypeFromExtension(mimeextn); Log.i("HLMS", fileuri + " " + mimetype); intent.setDataAndType(fileuri, mimetype); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); cordova.getActivity().getApplicationContext().startActivity(intent); callbackContext.success(); } catch (Exception e) { Log.e("HLMS", "exception", e); callbackContext.error(0); } return true; } else if ((action.compareTo("getfilesrv") == 0)) { this.mCallbackContext = callbackContext; cordova.getThreadPool().execute(new Runnable() { @Override public void run() { try { Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("*/*");// TODO: Restrict file types cordova.startActivityForResult(EliademyLms.this, intent, submitFileCode); } catch (Exception e) { Log.e("HLMS", "exception", e); callbackContext.error(0); } return; } }); } else if ((action.compareTo("initservice") == 0)) { if (!mIsBound) { this.mCallbackContext = callbackContext; JSONObject tmp = new JSONObject(data.getString(0)); String sname = tmp.getString("servicename"); if (sname.contains("eliademy")) { mServiceName = "com.cbtec.serviceeliademy"; } else { // From url determine version 2.2, 2.3, 2.4 and change mServiceName = "com.cbtec.service" + sname; } Log.i("HLMS", "Connecting to service: " + mServiceName); doBindService(); } else { callbackContext.success(); } return true; } else { final String aAction = action; final JSONArray aData = data; String mappedCmd = null; try { mappedCmd = mapExecCommand(aData.getString(0)); } catch (JSONException e) { Log.e("HLMS", "exception", e); } if (mappedCmd == null) { Log.i("HLMS", "LMS service call failed " + mappedCmd); callbackContext.error(0);// TODO : error enum return false; } final String execCmd = mappedCmd; cordova.getThreadPool().execute(new Runnable() { @Override @SuppressLint("NewApi") public void run() { Log.i("HLMS", "Runner execute " + aAction + aData.toString()); if (aAction.compareTo("lmsservice") == 0) { try { String retval = null; Log.i("HLMS", "Execute cmd: " + execCmd); if (execCmd.compareTo("initialize") == 0) { if (mIBinder.initializeService(aData.getString(1))) { String token = mIBinder.eliademyGetWebServiceToken(); callbackContext.success(token); return; } } else if (execCmd.compareTo("deinitialize") == 0) { if (mIBinder.deInitializeService(aData.getString(1))) { doUnbindService(); callbackContext.success(); return; } } else if (execCmd.compareTo("pushregister") == 0) { Log.i("pushdata", aData.getString(1)); if (mIBinder.registerPushNotifications(aData.getString(1))) { callbackContext.success(); return; } } else if (execCmd.compareTo("pushunregister") == 0) { Log.i("pushdata", aData.getString(1)); if (mIBinder.unregisterPushNotifications(aData.getString(1))) { callbackContext.success(); return; } } else if (execCmd.compareTo("servicetoken") == 0) { retval = mIBinder.eliademyGetWebServiceToken(); } else if (execCmd.compareTo("siteinfo") == 0) { retval = mIBinder.eliademyGetSiteInformation(aData.getString(1)); } else if (execCmd.compareTo("get_user_courses") == 0) { retval = mIBinder.eliademyGetUsersCourses(aData.getString(1)); } else if (execCmd.compareTo("get_user_forums") == 0) { retval = mIBinder.eliademyGetUserForums(aData.getString(1)); } else if (execCmd.compareTo("get_user_info") == 0) { retval = mIBinder.eliademyGetUserInformation(aData.getString(1)); } else if (execCmd.compareTo("exec_webservice") == 0) { Log.i("HLMS", "Execute webservice"); retval = mIBinder.eliademyExecWebService(aData.getString(0), aData.getString(1)); } else if (execCmd.compareTo("course_get_contents") == 0) { retval = mIBinder.eliademyGetCourseContents(aData.getString(1)); } else if (execCmd.compareTo("course_get_enrolled_users") == 0) { retval = mIBinder.eliademyGetEnrolledUsers(aData.getString(1)); } else { Log.i("HLMS", "LMS service failed " + execCmd); callbackContext.error(0);// TODO : error enum } if (!retval.isEmpty()) { Log.i("HLMS", "LMS service call success"); callbackContext.success(retval); } else { Log.i("HLMS", "LMS service call failed"); callbackContext.error(0);// TODO : error enum } } catch (Exception e) { Log.e("HLMS", "exception", e); callbackContext.error(e.getMessage()); return; } } else { Log.i("LMS", "Unsupported action call !!"); callbackContext.error(0); return; } } }); } return true; }
From source file:app.sunstreak.yourpisd.ClassSwipeActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { Intent intent; // Handle item selection switch (item.getItemId()) { case R.id.log_out: SharedPreferences.Editor editor = getPreferences(Context.MODE_PRIVATE).edit(); editor.putBoolean("auto_login", false); editor.commit();// ww w.j a v a2 s. co m intent = new Intent(this, LoginActivity.class); // Clear all activities between this and LoginActivity intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); return true; /* case R.id.refresh: Intent refreshIntent = new Intent(this, LoginActivity.class); refreshIntent.putExtra("Refresh", true); startActivity(refreshIntent); finish(); return true; */ case R.id.previous_six_weeks: intent = new Intent(this, ClassSwipeActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.putExtra("studentIndex", studentIndex); intent.putExtra("classCount", classCount); intent.putExtra("classIndex", mViewPager.getCurrentItem()); // Don't go into the negatives! intent.putExtra("termIndex", Math.max(termIndex - 1, 0)); startActivity(intent); // overridePendingTransition(R.anim.slide_in_down, R.anim.slide_out_up); return true; case R.id.next_six_weeks: intent = new Intent(this, ClassSwipeActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.putExtra("studentIndex", studentIndex); intent.putExtra("classCount", classCount); intent.putExtra("classIndex", mViewPager.getCurrentItem()); // Don't go too positive! intent.putExtra("termIndex", Math.min(termIndex + 1, 7)); startActivity(intent); // overridePendingTransition(R.anim.slide_in_up, R.anim.slide_out_down); return true; default: return super.onOptionsItemSelected(item); } }
From source file:com.perm.DoomPlay.PlayingService.java
private Notification createNotification() { Intent intentActivity; if (SettingActivity.getPreferences(SettingActivity.keyOnClickNotif)) { intentActivity = new Intent(FullPlaybackActivity.actionReturnFull); intentActivity.setClass(this, FullPlaybackActivity.class); intentActivity.putExtra(FileSystemActivity.keyMusic, audios); } else {// w w w. j a va 2 s . com intentActivity = FullPlaybackActivity.getReturnSmallIntent(this, audios); } intentActivity.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); Notification notification = new Notification(); notification.contentView = getNotifViews(R.layout.notif); notification.flags |= Notification.FLAG_FOREGROUND_SERVICE; notification.contentIntent = PendingIntent.getActivity(this, 0, intentActivity, PendingIntent.FLAG_UPDATE_CURRENT); notification.icon = isPlaying ? R.drawable.status_icon_pause : R.drawable.status_icon_play; return notification; }
From source file:fm.smart.r1.activity.ItemActivity.java
@Override public void onActivityResult(final int requestCode, final int resultCode, final Intent data) { super.onActivityResult(requestCode, resultCode, data); // this should be called once image has been chosen by user // using requestCode to pass item id - haven't worked out any other way // to do it//from w w w . ja v a 2 s .co m // if (requestCode == SELECT_IMAGE) if (resultCode == Activity.RESULT_OK) { // TODO check if user is logged in if (Main.isNotLoggedIn(this)) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setClassName(this, LoginActivity.class.getName()); intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); // avoid navigation back to this? LoginActivity.return_to = ItemActivity.class.getName(); LoginActivity.params = new HashMap<String, String>(); LoginActivity.params.put("item_id", (String) item.item_node.atts.get("id")); startActivity(intent); // TODO in this case forcing the user to rechoose the image // seems a little // rude - should probably auto-submit here ... } else { // Bundle extras = data.getExtras(); // String sentence_id = (String) extras.get("sentence_id"); final ProgressDialog myOtherProgressDialog = new ProgressDialog(this); myOtherProgressDialog.setTitle("Please Wait ..."); myOtherProgressDialog.setMessage("Uploading image ..."); myOtherProgressDialog.setIndeterminate(true); myOtherProgressDialog.setCancelable(true); final Thread add_image = new Thread() { public void run() { // TODO needs to check for interruptibility String sentence_id = Integer.toString(requestCode); Uri selectedImage = data.getData(); // Bitmap bitmap = Media.getBitmap(getContentResolver(), // selectedImage); // ByteArrayOutputStream bytes = new // ByteArrayOutputStream(); // bitmap.compress(Bitmap.CompressFormat.JPEG, 40, // bytes); // ByteArrayInputStream fileInputStream = new // ByteArrayInputStream( // bytes.toByteArray()); // TODO Might have to save to file system first to get // this // to work, // argh! // could think of it as saving to cache ... // add image to sentence FileInputStream is = null; FileOutputStream os = null; File file = null; ContentResolver resolver = getContentResolver(); try { Bitmap bitmap = Media.getBitmap(getContentResolver(), selectedImage); ByteArrayOutputStream bytes = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, 40, bytes); // ByteArrayInputStream bais = new // ByteArrayInputStream(bytes.toByteArray()); // FileDescriptor fd = // resolver.openFileDescriptor(selectedImage, // "r").getFileDescriptor(); // is = new FileInputStream(fd); String filename = "test.jpg"; File dir = ItemActivity.this.getDir("images", MODE_WORLD_READABLE); file = new File(dir, filename); os = new FileOutputStream(file); // while (bais.available() > 0) { // / os.write(bais.read()); // } os.write(bytes.toByteArray()); os.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { if (os != null) { try { os.close(); } catch (IOException e) { } } if (is != null) { try { is.close(); } catch (IOException e) { } } } // File file = new // File(Uri.decode(selectedImage.toString())); // ensure item is in users default list ItemActivity.add_item_result = addItemToList(Main.default_study_list_id, (String) item.item_node.atts.get("id"), ItemActivity.this); Result result = ItemActivity.add_item_result; if (ItemActivity.add_item_result.success() || ItemActivity.add_item_result.alreadyInList()) { // ensure sentence is in users default list ItemActivity.add_sentence_list_result = addSentenceToList(sentence_id, (String) item.item_node.atts.get("id"), Main.default_study_list_id, ItemActivity.this); result = ItemActivity.add_sentence_list_result; if (ItemActivity.add_sentence_list_result.success()) { String media_entity = "http://test.com/test.jpg"; String author = "tansaku"; String author_url = "http://smart.fm/users/tansaku"; Log.d("DEBUG-IMAGE-URI", selectedImage.toString()); ItemActivity.add_image_result = addImage(file, media_entity, author, author_url, "1", sentence_id, (String) item.item_node.atts.get("id"), Main.default_study_list_id); result = ItemActivity.add_image_result; } } final Result display = result; myOtherProgressDialog.dismiss(); ItemActivity.this.runOnUiThread(new Thread() { public void run() { final AlertDialog dialog = new AlertDialog.Builder(ItemActivity.this).create(); dialog.setTitle(display.getTitle()); dialog.setMessage(display.getMessage()); dialog.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { if (ItemActivity.add_image_result != null && ItemActivity.add_image_result.success()) { ItemListActivity.loadItem(ItemActivity.this, item.item_node.atts.get("id").toString()); } } }); dialog.show(); } }); } }; myOtherProgressDialog.setButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { add_image.interrupt(); } }); OnCancelListener ocl = new OnCancelListener() { public void onCancel(DialogInterface arg0) { add_image.interrupt(); } }; myOtherProgressDialog.setOnCancelListener(ocl); closeMenu(); myOtherProgressDialog.show(); add_image.start(); } } }
From source file:com.example.carsharing.LongWayActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { Intent returnp = new Intent(LongWayActivity.this, PersonalCenterActivity.class); returnp.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(returnp);//from ww w .ja va2 s .c o m return false; } else { return super.onKeyDown(keyCode, event); } }
From source file:com.perm.DoomPlay.PlayingService.java
private Notification createOldNotif() { NotificationCompat.Builder builder = new NotificationCompat.Builder(this); Intent intentActivity; if (SettingActivity.getPreferences(SettingActivity.keyOnClickNotif)) { intentActivity = new Intent(FullPlaybackActivity.actionReturnFull); intentActivity.setClass(this, FullPlaybackActivity.class); intentActivity.putExtra(FileSystemActivity.keyMusic, audios); } else {//from w w w. j a va 2 s. co m intentActivity = FullPlaybackActivity.getReturnSmallIntent(this, audios); } intentActivity.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); builder.setContentIntent( PendingIntent.getActivity(this, 0, intentActivity, PendingIntent.FLAG_UPDATE_CURRENT)) .setOngoing(true) .setSmallIcon(isPlaying ? R.drawable.status_icon_pause : R.drawable.status_icon_play); Audio audio = audios.get(indexCurrentTrack); builder.setContentTitle(audio.getTitle()); builder.setContentText(audio.getArtist()); Bitmap cover = AlbumArtGetter.getBitmapFromStore(audio.getAid(), this); if (cover == null) { Bitmap tempBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.fallback_cover); builder.setLargeIcon(tempBitmap); tempBitmap.recycle(); } else { builder.setLargeIcon(cover); cover.recycle(); } return builder.build(); }
From source file:dk.ciid.android.infobooth.activities.IntroductionActivity.java
private void changeActivity(String activityName) { Intent openActivity = new Intent(activityName); openActivity.putExtra("isInDebugMode", isInDebugMode); openActivity.putExtra("serviceNameItems", serviceNameItems); openActivity.putExtra("serviceDescItems", serviceDescItems); openActivity.putExtra("voice1", voice1); openActivity.putExtra("voice2", voice2); openActivity.putExtra("voice3", voice3); openActivity.putExtra("voice4", voice4); openActivity.putExtra("voice5", voice5); openActivity.putExtra("voice6", voice6); openActivity.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); startActivity(openActivity);/* w ww . jav a 2 s.c o m*/ closeAccessory(); }