List of usage examples for android.content Intent putExtra
@Deprecated
@UnsupportedAppUsage
public @NonNull Intent putExtra(String name, IBinder value)
From source file:Main.java
public static void jumpPostToNewActivity(final Context context, final Class<? extends Activity> targetClass, final int second, final String... datas) { (new AsyncTask<String, Integer, Boolean>() { protected Boolean doInBackground(String... params) { try { Thread.sleep((long) (second * 1000)); } catch (Exception var3) { ;/*from w ww . j a v a 2 s. c o m*/ } return null; } protected void onPostExecute(Boolean result) { super.onPostExecute(result); Intent datatIntent = new Intent(context, targetClass); datatIntent.setFlags(268435456); if (datas != null) { for (int i = 0; i < datas.length; ++i) { datatIntent.putExtra("data" + i, datas[i]); } } context.startActivity(datatIntent); } }).execute(new String[] { "" }); }
From source file:Main.java
public static void jumpPostToNewTopActivity(final Context context, final Class<? extends Activity> targetClass, final int second, final String... datas) { (new AsyncTask<String, Integer, Boolean>() { protected Boolean doInBackground(String... params) { try { Thread.sleep((long) (second * 1000)); } catch (Exception var3) { ;/* w w w . j a va2 s . co m*/ } return null; } protected void onPostExecute(Boolean result) { super.onPostExecute(result); Intent datatIntent = new Intent(context, targetClass); datatIntent.setFlags(335544320); if (datas != null) { for (int i = 0; i < datas.length; ++i) { datatIntent.putExtra("data" + i, datas[i]); } } context.startActivity(datatIntent); } }).execute(new String[] { "" }); }
From source file:Main.java
/** * send a message to call the emergency with location of the accident * * @param latitude/*from ww w .j a v a 2s.c o m*/ * @param longitude */ public static void sendEmergencyToMessages(double latitude, double longitude, Context context) { Intent sendSmsIntent = new Intent(Intent.ACTION_VIEW); sendSmsIntent.setData(Uri.parse("sms:")); sendSmsIntent.setType("vnd.android-dir/mms-sms"); String message = "The Car had accident at: " + latitude + " , " + longitude; sendSmsIntent.putExtra(Intent.EXTRA_TEXT, message); if (sendSmsIntent.resolveActivity(context.getPackageManager()) != null) { context.startActivity(sendSmsIntent); } }
From source file:it.uniroma2.foundme.studente.ShowCourseActivity.java
public static void populateView(String[] result) { courses = new String[result.length]; System.arraycopy(result, 0, courses, 0, result.length); List<Map<String, String>> data = new ArrayList<Map<String, String>>(); for (int i = 0; i < result.length; i++) { Map<String, String> datum = new HashMap<String, String>(2); if (i == 0 && result[0].equalsIgnoreCase(Variables_it.NO_COURSE)) { datum.put(Variables_it.COURSE, result[0]); datum.put(Variables_it.PROF, ""); data.add(datum);//w ww . j a v a 2 s . c om break; } else { String[] items = result[i].split(","); datum.put(Variables_it.COURSE, items[0]); datum.put(Variables_it.PROF, items[1]); data.add(datum); } } //creo l'adapter SimpleAdapter adapter = new SimpleAdapter(context, data, android.R.layout.simple_list_item_2, new String[] { Variables_it.COURSE, Variables_it.PROF }, new int[] { android.R.id.text1, android.R.id.text2 }); lvCorsiSeguiti.setAdapter(adapter); swipeShow.setColorSchemeColors(0xff429874, 0xffffffff, 0xff429874, 0xffffffff); swipeShow.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { swipeShow.setRefreshing(true); (new Handler()).postDelayed(new Runnable() { @Override public void run() { swipeShow.setRefreshing(false); try { getCourse(false); } catch (ExecutionException e) { e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } } }, 3000); } }); lvCorsiSeguiti.setOnItemClickListener(new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (!courses[position].equalsIgnoreCase(Variables_it.NO_COURSE)) { Intent i = new Intent(context, CourseActivity.class); i.putExtra(Variables_it.COURSE, courses[position]); ((Activity) context).startActivity(i); } } }); lvCorsiSeguiti.setOnScrollListener(new AbsListView.OnScrollListener() { @Override public void onScrollStateChanged(AbsListView absListView, int i) { } @Override public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount, int totalItemCount) { if (firstVisibleItem == 0) swipeShow.setEnabled(true); else swipeShow.setEnabled(false); } }); }
From source file:net.frygo.findmybuddy.GCMIntentService.java
private static void generateNotification(Context context, String message) { Random rand = new Random(); int x = rand.nextInt(); NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); String title = context.getString(R.string.app_name); Intent notificationIntent = new Intent(context, customlistview.class); notificationIntent.putExtra("alert", message); message = message + " would like to add you as friend"; PendingIntent intent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_CANCEL_CURRENT); Notification notification = new Notification(R.drawable.logo, message, System.currentTimeMillis()); notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); notification.setLatestEventInfo(context, title, message, intent); notification.flags |= Notification.FLAG_AUTO_CANCEL; notificationManager.notify(x, notification); PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE); final PowerManager.WakeLock mWakelock = pm .newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, title); mWakelock.acquire();//from ww w .j a va 2s .c o m // Timer before putting Android Device to sleep mode. Timer timer = new Timer(); TimerTask task = new TimerTask() { public void run() { mWakelock.release(); } }; timer.schedule(task, 5000); }
From source file:cc.softwarefactory.lokki.android.services.LocationService.java
public static void run1min(Context context) { if (serviceRunning || !MainApplication.visible) { return; // If service is running, stop }//from w w w . j a va 2 s . c om Log.e(TAG, "run1min called"); Intent intent = new Intent(context, LocationService.class); intent.putExtra(RUN_1_MIN, 1); context.startService(intent); }
From source file:Main.java
public static void shareText(Context context, String title, String subject, String text, String mime) { Intent share = new Intent(Intent.ACTION_SEND); share.setType(mime);/*from w w w. ja v a2s .co m*/ share.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET | Intent.FLAG_ACTIVITY_NEW_DOCUMENT); // Add data to the intent, the receiving app will decide // what to do with it. share.putExtra(Intent.EXTRA_SUBJECT, subject); share.putExtra(Intent.EXTRA_TEXT, text); context.startActivity(Intent.createChooser(share, title)); }
From source file:Main.java
public static void goToMiuiPermissionActivity_V8(Context context) { Intent intent = new Intent("miui.intent.action.APP_PERM_EDITOR"); intent.setClassName("com.miui.securitycenter", "com.miui.permcenter.permissions.PermissionsEditorActivity"); // intent.setPackage("com.miui.securitycenter"); intent.putExtra("extra_pkgname", context.getPackageName()); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); if (isIntentAvailable(intent, context)) { context.startActivity(intent);/*from w ww . j a va2 s. co m*/ } else { intent = new Intent("miui.intent.action.APP_PERM_EDITOR"); intent.setPackage("com.miui.securitycenter"); intent.putExtra("extra_pkgname", context.getPackageName()); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); if (isIntentAvailable(intent, context)) { context.startActivity(intent); } else { Log.e(TAG, "Intent is not available!"); } } }
From source file:Main.java
public static Intent getSettingLSWallpaperIntent() { Intent intent = new Intent(); intent.setComponent(new ComponentName("com.asus.launcher", "com.asus.themeapp.ThemeAppActivity")); intent.addFlags(//from w w w . ja v a2s . c om Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); intent.putExtra("tabPosition", 1); return intent; }
From source file:Main.java
public static Intent getSettingLSThemeIntent() { Intent intent = new Intent(); intent.setComponent(new ComponentName("com.asus.themeapp", "com.asus.themeapp.ThemeAppActivity")); intent.addFlags(/*from ww w . j a v a2 s . c o m*/ Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); intent.putExtra("from", "com.android.systemui.lockscreen"); return intent; }