List of usage examples for android.content Intent putExtras
public @NonNull Intent putExtras(@NonNull Bundle extras)
From source file:com.firescar96.nom.GCMIntentService.java
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) private static void Notify(String notificationTitle, String notificationMessage, Bundle data, int id, boolean annoy) { NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(thisService) .setSmallIcon(R.drawable.ic_launcher).setContentTitle(notificationTitle) .setContentText(notificationMessage).setAutoCancel(true); // Creates an explicit intent for an Activity in your app Intent resultIntent = new Intent(thisService, MainActivity.class); resultIntent.putExtras(data); // The stack builder object will contain an artificial back stack for the // started Activity. // This ensures that navigating backward from the Activity leads out of // your application to the Home screen. TaskStackBuilder stackBuilder = TaskStackBuilder.create(thisService); // Adds the back stack for the Intent (but not the Intent itself) stackBuilder.addParentStack(MainActivity.class); // Adds the Intent that starts the Activity to the top of the stack stackBuilder.addNextIntent(resultIntent); PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); mBuilder.setContentIntent(resultPendingIntent); if (annoy) {//from w w w .j a va 2 s . c om Uri alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); mBuilder.setSound(alarmSound); long[] pattern = { 50, 100, 10, 100, 10, 200 }; mBuilder.setVibrate(pattern); } NotificationManager mNotificationManager = (NotificationManager) thisService .getSystemService(Context.NOTIFICATION_SERVICE); // mId allows you to update the notification later on. mNotificationManager.notify(id, mBuilder.build()); }
From source file:org.c99.SyncProviderDemo.ContactsSyncAdapterService.java
private static void generateNotification(Noticia noticia, Context context) { NotificationManager mNotificationManager; int numMessages = 0; Log.i("Start", "notification"); /* Invoking the default notification service */ NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context); mBuilder.setContentTitle("Nova noticia"); mBuilder.setContentText(noticia.getAssunto()); mBuilder.setTicker("Noticia !!!"); mBuilder.setSmallIcon(R.drawable.logo); /* Increase notification number every time a new notification arrives */ mBuilder.setNumber(++numMessages);//from w ww . j a v a 2 s . c o m /* Creates an explicit intent for an Activity in your app */ Intent resultIntent = new Intent(context, NavigationDrawer.class); resultIntent.setAction("NOTICIA"); //tentando linkar Bundle bundle = new Bundle(); bundle.putSerializable("noticia", noticia); resultIntent.putExtras(bundle); // fim arrumar a inteao TaskStackBuilder stackBuilder = TaskStackBuilder.create(context); stackBuilder.addParentStack(NavigationDrawer.class); /* Adds the Intent that starts the Activity to the top of the stack */ stackBuilder.addNextIntent(resultIntent); PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); mBuilder.setContentIntent(resultPendingIntent); mNotificationManager = // (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); // (NotificationManager) getActivity().getApplication(). // getSystemService(getActivity().getApplication().NOTIFICATION_SERVICE); // (NotificationManager) getContext().getSystemService(getContext().NOTIFICATION_SERVICE); // (NotificationManager) getSystemService(NOTIFICATION_SERVICE); (NotificationManager) context.getSystemService(NOTIFICATION_SERVICE); /* notificationID allows you to update the notification later on. */ mNotificationManager.notify(noticia.getCodigo(), mBuilder.build()); }
From source file:org.c99.SyncProviderDemo.EventosSyncAdapterService.java
private static void generateNotification(Evento evento, Context context) { NotificationManager mNotificationManager; int numMessages = 0; Log.i("Start", "notification"); /* Invoking the default notification service */ NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context); mBuilder.setContentTitle("Novo evento"); mBuilder.setContentText(evento.getNome()); mBuilder.setTicker("Evento !!!"); mBuilder.setSmallIcon(R.drawable.logo); /* Increase notification number every time a new notification arrives */ mBuilder.setNumber(++numMessages);//w w w. ja v a 2 s .co m /* Creates an explicit intent for an Activity in your app */ Intent resultIntent = new Intent(context, NavigationDrawer.class); resultIntent.setAction("EVENTO"); //tentando linkar Bundle bundle = new Bundle(); bundle.putSerializable("evento", evento); resultIntent.putExtras(bundle); // fim arrumar a inteao TaskStackBuilder stackBuilder = TaskStackBuilder.create(context); stackBuilder.addParentStack(NavigationDrawer.class); /* Adds the Intent that starts the Activity to the top of the stack */ stackBuilder.addNextIntent(resultIntent); PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); mBuilder.setContentIntent(resultPendingIntent); mNotificationManager = // (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); // (NotificationManager) getActivity().getApplication(). // getSystemService(getActivity().getApplication().NOTIFICATION_SERVICE); /* notificationID allows you to update the notification later on. */ // (NotificationManager) getApplication().getSystemService(NOTIFICATION_SERVICE); (NotificationManager) context.getSystemService(NOTIFICATION_SERVICE); mNotificationManager.notify(evento.getCodigo(), mBuilder.build()); }
From source file:com.xiaomi.account.utils.SysHelper.java
public static Intent buildPreviousActivityIntent(Context context, Intent current, Class<? extends Activity> previous) { Intent intent = new Intent(context, previous); if (!(current == null || current.getExtras() == null)) { intent.putExtras(current.getExtras()); }/* w w w. j a v a2s . c o m*/ intent.putExtra(Constants.EXTRA_FROM_BACK_NAVIGATION, true); intent.addFlags(67108864); return intent; }
From source file:com.fastaccess.ui.modules.repos.RepoPagerActivity.java
public static Intent createIntent(@NonNull Context context, @NonNull String repoId, @NonNull String login, @RepoPagerMvp.RepoNavigationType int navType) { Intent intent = new Intent(context, RepoPagerActivity.class); intent.putExtras(Bundler.start().put(BundleConstant.ID, repoId).put(BundleConstant.EXTRA_TWO, login) .put(BundleConstant.EXTRA_TYPE, navType).end()); return intent; }
From source file:com.fastaccess.ui.modules.repos.RepoPagerActivity.java
public static void startRepoPager(@NonNull Context context, @NonNull NameParser nameParser) { if (!InputHelper.isEmpty(nameParser.getName()) && !InputHelper.isEmpty(nameParser.getUsername())) { Intent intent = new Intent(context, RepoPagerActivity.class); intent.putExtras(Bundler.start().put(BundleConstant.ID, nameParser.getName()) .put(BundleConstant.EXTRA_TWO, nameParser.getUsername()) .put(BundleConstant.EXTRA_TYPE, RepoPagerMvp.CODE) .put(BundleConstant.IS_ENTERPRISE, nameParser.isEnterprise()).end()); context.startActivity(intent);/*from w w w .j a va 2s . c o m*/ } }
From source file:it.evilsocket.dsploit.core.System.java
public static boolean checkNetworking(final Activity current) { if (Network.isWifiConnected(mContext) == false) { AlertDialog.Builder builder = new AlertDialog.Builder(current); builder.setCancelable(false);/* w ww . ja va2 s. co m*/ builder.setTitle("Error"); builder.setMessage("WiFi connectivity went down."); builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); Bundle bundle = new Bundle(); bundle.putBoolean(WifiScannerActivity.CONNECTED, false); Intent intent = new Intent(); intent.putExtras(bundle); current.setResult(Activity.RESULT_OK, intent); current.finish(); } }); AlertDialog alert = builder.create(); alert.show(); return false; } return true; }
From source file:com.zzl.zl_app.cache.Utility.java
public static boolean loadFile(String loadpath, String fileName, String savePath, Context context, String broadcastAction) { FileOutputStream fos = null; // ? FileInputStream fis = null; // ? InputStream is = null; // ? HttpURLConnection httpConnection = null; int readLength = 0; // ?? int file_length = 0; URL url = null;//from w w w . j ava2 s . co m try { url = new URL(loadpath); httpConnection = (HttpURLConnection) url.openConnection(); httpConnection.setConnectTimeout(10000); httpConnection.setRequestMethod("GET"); is = httpConnection.getInputStream(); FileTools.creatDir(savePath); String filePath = savePath + fileName; FileTools.deleteFile(filePath); FileTools.creatFile(filePath); File download_file = new File(filePath); fos = new FileOutputStream(download_file, true); // ?? fis = new FileInputStream(download_file); // ?? int total_read = fis.available(); // ??0 file_length = httpConnection.getContentLength(); // ? if (is == null) { // ? Tools.log("Voice", "donload failed..."); return false; } byte buf[] = new byte[3072]; // readLength = 0; // Tools.log("Voice", "download start..."); Intent startIntent = new Intent(); Bundle b = new Bundle(); if (broadcastAction != null) { // ????? b.putInt("fileSize", file_length); b.putInt("progress", 0); startIntent.putExtras(b); startIntent.setAction(broadcastAction); context.sendBroadcast(startIntent); } // ????? while (readLength != -1) { if ((readLength = is.read(buf)) > 0) { fos.write(buf, 0, readLength); total_read += readLength; // } if (broadcastAction != null) { b.putInt("fileSize", file_length); b.putInt("progress", total_read); startIntent.putExtras(b); startIntent.setAction(broadcastAction); context.sendBroadcast(startIntent); } if (total_read == file_length) { // ? Tools.log("Voice", "download complete..."); // ?????? if (broadcastAction != null) { Intent completeIntent = new Intent(); b.putBoolean("isFinish", true); completeIntent.putExtras(b); completeIntent.setAction(broadcastAction); context.sendBroadcast(completeIntent); } } // Thread.sleep(10); // ?10 } } catch (Exception e) { if (broadcastAction != null) { Intent errorIntent = new Intent(); errorIntent.setAction(broadcastAction); context.sendBroadcast(errorIntent); e.printStackTrace(); } } finally { try { if (fos != null) { fos.close(); } if (fis != null) { is.close(); } if (fis != null) { fis.close(); } } catch (IOException e) { e.printStackTrace(); } } return true; }
From source file:cn.jarlen.richcommon.ui.BaseActivity.java
protected void startActivity(Class<?> activity, Bundle args) { Intent intent = new Intent(this, activity); if (args != null) { intent.putExtras(args); }/* w w w. j av a 2 s . c o m*/ startActivity(intent); }
From source file:cn.jarlen.richcommon.ui.BaseActivity.java
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) protected void startActivityForResult(Class<?> activity, int requestCode, Bundle args) { Intent intent = new Intent(this, activity); if (args != null) { intent.putExtras(args); }/*from w ww. ja va2 s. co m*/ startActivityForResult(intent, requestCode, args); }