List of usage examples for android.content Intent setAction
public @NonNull Intent setAction(@Nullable String action)
From source file:com.perm.DoomPlay.VkAlbumsActivity.java
@Override protected void startListVkActivity(ArrayList<Audio> audios) { Intent intent = new Intent(this, ListVkActivity.class); intent.setAction(ListVkActivity.actionMyAlbums); intent.putExtra(MainScreenActivity.keyOpenInListTrack, audios); startActivity(intent);//ww w. j a v a 2s.com }
From source file:com.raspi.chatapp.util.Notification.java
public void createNotification(String buddyId, String name, String message, String type) { SharedPreferences defaultSharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); if (defaultSharedPreferences .getBoolean(context.getResources().getString(R.string.pref_key_new_message_notifications), true)) { int index = buddyId.indexOf("@"); if (index != -1) buddyId = buddyId.substring(0, index); if (name == null) name = buddyId;/*from w ww.ja va2s. c o m*/ Log.d("DEBUG", "creating notification: " + buddyId + "|" + name + "|" + message); Intent resultIntent = new Intent(context, ChatActivity.class); resultIntent.setAction(NOTIFICATION_CLICK); String oldBuddyId = getOldBuddyId(); Log.d("DEBUG", (oldBuddyId == null) ? ("oldBuddy is null (later " + buddyId) : ("oldBuddy: " + oldBuddyId)); if (oldBuddyId == null || oldBuddyId.equals("")) { oldBuddyId = buddyId; setOldBuddyId(buddyId); } if (oldBuddyId.equals(buddyId)) { resultIntent.putExtra(Constants.BUDDY_ID, buddyId); resultIntent.putExtra(Constants.CHAT_NAME, name); } TaskStackBuilder stackBuilder = TaskStackBuilder.create(context); stackBuilder.addParentStack(ChatActivity.class); stackBuilder.addNextIntent(resultIntent); PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); NotificationManager nm = ((NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE)); NotificationCompat.Style style; String[] previousNotifications = readJSONArray(CURRENT_NOTIFICATIONS); String title; String[] currentNotifications = Arrays.copyOf(previousNotifications, previousNotifications.length + 1); currentNotifications[currentNotifications.length - 1] = name + ": " + message; if (previousNotifications.length == 0) { style = new NotificationCompat.BigTextStyle(); NotificationCompat.BigTextStyle bigTextStyle = ((NotificationCompat.BigTextStyle) style); title = context.getResources().getString(R.string.new_message) + " " + context.getResources().getString(R.string.from) + " " + name; bigTextStyle.bigText(currentNotifications[0]); bigTextStyle.setBigContentTitle(title); } else { style = new NotificationCompat.InboxStyle(); NotificationCompat.InboxStyle inboxStyle = (NotificationCompat.InboxStyle) style; title = (previousNotifications.length + 1) + " " + context.getResources().getString(R.string.new_messages); for (String s : currentNotifications) if (s != null && !"".equals(s)) inboxStyle.addLine(s); inboxStyle.setSummaryText( (currentNotifications.length > 2) ? ("+" + (currentNotifications.length - 2) + " more") : null); inboxStyle.setBigContentTitle(title); } writeJSONArray(currentNotifications, CURRENT_NOTIFICATIONS); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context).setContentTitle(title) .setContentText(currentNotifications[currentNotifications.length - 1]) .setSmallIcon(MessageHistory.TYPE_TEXT.equals(type) ? R.drawable.ic_forum_white_48dp : R.drawable.ic_photo_camera_white_48dp) .setLargeIcon(getLargeIcon(Character.toUpperCase(name.toCharArray()[0]))).setStyle(style) .setAutoCancel(true).setPriority(5).setContentIntent(resultPendingIntent); String str = context.getResources().getString(R.string.pref_key_privacy); mBuilder.setVisibility(context.getResources().getString(R.string.pref_value1_privacy).equals(str) ? NotificationCompat.VISIBILITY_SECRET : context.getResources().getString(R.string.pref_value2_privacy).equals(str) ? NotificationCompat.VISIBILITY_PRIVATE : NotificationCompat.VISIBILITY_PUBLIC); str = context.getResources().getString(R.string.pref_key_vibrate); if (defaultSharedPreferences.getBoolean(str, true)) mBuilder.setVibrate(new long[] { 800, 500, 800, 500 }); str = context.getResources().getString(R.string.pref_key_led); if (defaultSharedPreferences.getBoolean(str, true)) mBuilder.setLights(Color.BLUE, 500, 500); str = defaultSharedPreferences.getString(context.getResources().getString(R.string.pref_key_ringtone), ""); mBuilder.setSound("".equals(str) ? RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION) : Uri.parse(str)); nm.notify(NOTIFICATION_ID, mBuilder.build()); str = context.getResources().getString(R.string.pref_key_banner); if (!defaultSharedPreferences.getBoolean(str, true)) { try { Thread.sleep(1500); } catch (InterruptedException e) { } reset(); } } }
From source file:net.openid.appauthdemo.Configuration.java
private boolean isRedirectUriRegistered() { // ensure that the redirect URI declared in the configuration is handled by some activity // in the app, by querying the package manager speculatively Intent redirectIntent = new Intent(); redirectIntent.setPackage(mContext.getPackageName()); redirectIntent.setAction(Intent.ACTION_VIEW); redirectIntent.addCategory(Intent.CATEGORY_BROWSABLE); redirectIntent.setData(mRedirectUri); return !mContext.getPackageManager().queryIntentActivities(redirectIntent, 0).isEmpty(); }
From source file:dk.dr.radio.data.DRData.java
public void kundividi(Activity akt) { Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_SUBJECT, "Esperanto-radio por Androjd"); sendIntent.putExtra(Intent.EXTRA_TEXT, "Saluton!\n\n" + "Mi rekomendas ke vi elprovas tiun i programon per via Androjda telefono:\n" + "La Esperanto-radio de Muzaiko\n" + "https://market.android.com/details?id=dk.nordfalk.esperanto.radio\n" + "\n" + "Muzaiko estas Esperanto-radio kiu konstante elsendas.\n" + "Eblas anka askulti la lastatempajn elsendojn de deko da aliaj radistacioj." // +"\n\n(kaj... ne forgesu meti 5 stelojn :-)" );/*from w ww. ja v a 2s.co m*/ sendIntent.setType("text/plain"); akt.startActivity(Intent.createChooser(sendIntent, "Sendi al")); }
From source file:com.openerp.addons.messages.MessageSyncHelper.java
/** * Handle message response./*from w w w . ja v a 2 s. co m*/ * * @param db * the db * @param response * the response * @return the int */ private int handleMessageResponse(BaseDBHelper db, JSONObject response) { String[] columns = db.columnListToStringArray(db.getServerColumns()); ContentValues values = new ContentValues(); int newId = 0; try { for (String column : columns) { if (response.has(column)) { values.put(column, response.getString(column)); } } if (values.get("subject").toString().equals("false")) { values.put("subject", response.getString("record_name")); } String author = "false"; String email_from = "false"; if (response.getJSONArray("author_id").getString(0).equals("0")) { email_from = response.getJSONArray("author_id").getString(1).toString(); } else { author = response.getString("author_id"); } values.put("author_id", author); values.put("email_from", email_from); String parent_id = "false"; if (!response.getString("parent_id").equals("false")) { if (response.get("parent_id") instanceof JSONArray) { parent_id = response.getJSONArray("parent_id").getString(0); } else { parent_id = response.getString("parent_id"); } } values.put("parent_id", parent_id); String starred = "false"; if (response.has("is_favorite")) { if (response.getString("is_favorite").equals("true")) { starred = "true"; } } values.put("starred", starred); if (!db.hasRecord(db, response.getInt("id"))) { // Sending Broadcast message for data set change. Intent intent = new Intent(); intent.setAction(DataSetChangeReceiver.DATA_CHANGED); newId = db.create(db, values); intent.putExtra("id", String.valueOf(newId)); intent.putExtra("parent_id", parent_id); mContext.sendBroadcast(intent); } } catch (Exception e) { e.printStackTrace(); } return newId; }
From source file:no.uka.findmyapp.android.rest.client.RestProcessor.java
/** * Send intent broadcast./*from w ww . j a v a 2 s. c o m*/ * * @param intentString the intent string * @param obj the obj */ private void sendIntentBroadcast(String intentString, Serializable obj) { Log.v(debug, "sendIntentBroadcast: sending broadcast, object name " + obj.getClass().getName()); Log.v(debug, "sendIntentBroadcast: broadcast sent, extradata identifier: " + IntentMessages.BROADCAST_RETURN_VALUE_NAME); Log.v(debug, "sendIntentBroadcast: Putting extra " + obj.toString()); Intent broadcastedIntent = new Intent(); broadcastedIntent.putExtra(IntentMessages.BROADCAST_RETURN_VALUE_NAME, obj); broadcastedIntent.setAction(intentString); mContext.sendBroadcast(broadcastedIntent); }
From source file:edu.mines.letschat.GcmIntentService.java
@Override protected void onHandleIntent(Intent intent) { Bundle extras = intent.getExtras();//from w w w. j av a 2s . c om GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this); // The getMessageType() intent parameter must be the intent you received // in your BroadcastReceiver. String messageType = gcm.getMessageType(intent); if (!extras.isEmpty()) { // has effect of unparcelling Bundle /* * Filter messages based on message type. Since it is likely that GCM will be * extended in the future with new message types, just ignore any message types you're * not interested in, or that you don't recognize. */ if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) { sendNotification("Send error: " + extras.toString(), "0"); } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { sendNotification("Deleted messages on server: " + extras.toString(), "0"); // If it's a regular GCM message, do some work. } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { // This loop represents the service doing some work. // for (int i = 0; i < 5; i++) { // Log.i(TAG, "Working... " + (i + 1) // + "/5 @ " + SystemClock.elapsedRealtime()); // try { // Thread.sleep(5000); // } catch (InterruptedException e) { // } // } Log.i(TAG, "Completed work @ " + SystemClock.elapsedRealtime()); // Post notification of received message. String message = (String) extras.get("message"); messages.add(message); String picture = (String) extras.get("picture"); String senderID = (String) extras.get("sender"); String recipientID = (String) extras.get("recipient"); sendNotification(message, senderID); Log.v(TAG, "Received: " + message); Log.i(TAG, "Received: " + extras.toString()); Intent resultBroadCastIntent = new Intent(); /*set action here*/ resultBroadCastIntent.setAction( edu.mines.letschat.MessageActivity.TextCapitalizeResultReceiver.ACTION_TEXT_CAPITALIZED); /*set intent category as default*/ resultBroadCastIntent.addCategory(Intent.CATEGORY_DEFAULT); /*add data to intent*/ resultBroadCastIntent.putExtra(OUTPUT_TEXT, message); // Log.v(TAG, "Sender id " + senderID + " recieve id " + recipientID); Log.v(TAG, picture); Conversation convo = new Conversation(getApplicationContext(), senderID, recipientID, message, false, picture); convo.save(); if (!picture.isEmpty()) { new DownloadImage(picture).execute(); } /*send broadcast */ sendBroadcast(resultBroadCastIntent); } } // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReviever.completeWakefulIntent(intent); }
From source file:com.bdcorps.videonews.MainActivity.java
@Override public void onInit(int status) { // status can be either TextToSpeech.SUCCESS or TextToSpeech.ERROR if (status == TextToSpeech.SUCCESS) { // Set preferred language to US english. // Note that a language may not be available, and the topicNames will indicate this. int result = mTts.setLanguage(Locale.US); mTts.setOnUtteranceCompletedListener(this); if (result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED) { // Lanuage data is missing or the language is not supported. Log.e("404", "Language is not available."); }// w ww.j a v a 2 s .co m } else { // Initialization failed. Log.e("404", "Could not initialize TextToSpeech."); // May be its not installed so we prompt it to be installed Intent installIntent = new Intent(); installIntent.setAction(TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA); startActivity(installIntent); } }
From source file:com.cloverstudio.spika.GCMIntentService.java
@SuppressWarnings("deprecation") public void triggerNotification(Context context, String message, String fromName, Bundle pushExtras) { if (fromName != null) { final NotificationManager notificationManager = (NotificationManager) getSystemService( NOTIFICATION_SERVICE);//from w w w . j av a 2 s .c o m Notification notification = new Notification(R.drawable.icon_notification, message, System.currentTimeMillis()); notification.number = mNotificationCounter + 1; mNotificationCounter = mNotificationCounter + 1; Intent intent = new Intent(this, SplashScreenActivity.class); intent.replaceExtras(pushExtras); intent.putExtra(Const.PUSH_INTENT, true); intent.setAction(Long.toString(System.currentTimeMillis())); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_FROM_BACKGROUND | Intent.FLAG_ACTIVITY_TASK_ON_HOME); PendingIntent pendingIntent = PendingIntent.getActivity(this, notification.number, intent, PendingIntent.FLAG_UPDATE_CURRENT); notification.setLatestEventInfo(this, context.getString(R.string.app_name), message, pendingIntent); notification.defaults |= Notification.DEFAULT_VIBRATE; notification.defaults |= Notification.DEFAULT_SOUND; notification.flags |= Notification.FLAG_AUTO_CANCEL; String notificationId = Double.toString(Math.random()); notificationManager.notify(notificationId, 0, notification); } }
From source file:com.seal.ui.components.CustomWebView.java
private Intent createIntent(String action, int actionId, int hitTestResult, String url) { Intent result = new Intent(getContext(), SealBrowserActivity.class); result.setAction(action); result.putExtra(Constants.EXTRA_ACTION_ID, actionId); result.putExtra(Constants.EXTRA_HIT_TEST_RESULT, hitTestResult); result.putExtra(Constants.EXTRA_URL, url); result.putExtra(Constants.EXTRA_INCOGNITO, isPrivateBrowsingEnabled()); return result; }