List of usage examples for android.content Intent hasExtra
public boolean hasExtra(String name)
From source file:com.piusvelte.taplock.client.core.TapLockService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { if (intent != null) { String action = intent.getAction(); if (BluetoothAdapter.ACTION_STATE_CHANGED.equals(action)) { int state = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, BluetoothAdapter.STATE_OFF); if (state == BluetoothAdapter.STATE_ON) { if (mStartedBT) { if (mUIInterface != null) { try { mUIInterface.setMessage("Bluetooth enabled"); } catch (RemoteException e) { Log.e(TAG, e.getMessage()); }/*from w w w . j a v a 2 s . c o m*/ } if ((mQueueAddress != null) && (mQueueState != null)) requestWrite(mQueueAddress, mQueueState, mQueuePassphrase); else if (mRequestDiscovery && !mBtAdapter.isDiscovering()) mBtAdapter.startDiscovery(); else if (mUIInterface != null) { try { mUIInterface.setBluetoothEnabled(); } catch (RemoteException e) { Log.e(TAG, e.getMessage()); } } } } else if (state == BluetoothAdapter.STATE_TURNING_OFF) { if (mUIInterface != null) { try { mUIInterface.setMessage("Bluetooth disabled"); } catch (RemoteException e) { Log.e(TAG, e.getMessage()); } } stopThreads(); } } else if (BluetoothDevice.ACTION_FOUND.equals(action)) { // Get the BluetoothDevice object from the Intent BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); if (device.getBondState() == BluetoothDevice.BOND_BONDED) { // connect if configured String address = device.getAddress(); for (JSONObject deviceJObj : mDevices) { try { if (deviceJObj.getString(KEY_ADDRESS).equals(address)) { // if queued mDeviceFound = (mQueueAddress != null) && mQueueAddress.equals(address) && (mQueueState != null); break; } } catch (JSONException e) { Log.e(TAG, e.getMessage()); } } } else if (mRequestDiscovery && (mUIInterface != null)) { String unpairedDevice = TapLock .createDevice(device.getName(), device.getAddress(), DEFAULT_PASSPHRASE).toString(); try { mUIInterface.setUnpairedDevice(unpairedDevice); } catch (RemoteException e) { Log.e(TAG, e.getMessage()); } } } else if (BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(action)) { if (mDeviceFound) { requestWrite(mQueueAddress, mQueueState, mQueuePassphrase); mDeviceFound = false; } else if (mRequestDiscovery) { mRequestDiscovery = false; if (mUIInterface != null) { try { mUIInterface.setDiscoveryFinished(); } catch (RemoteException e) { Log.e(TAG, e.toString()); } } } } else if (ACTION_TOGGLE.equals(action) && intent.hasExtra(EXTRA_DEVICE_ADDRESS)) { String address = intent.getStringExtra(EXTRA_DEVICE_ADDRESS); requestWrite(address, ACTION_TOGGLE, null); } else if (AppWidgetManager.ACTION_APPWIDGET_UPDATE.equals(action)) { // create widget if (intent.hasExtra(AppWidgetManager.EXTRA_APPWIDGET_ID)) { int appWidgetId = intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID); if (intent.hasExtra(EXTRA_DEVICE_NAME)) { // add a widget String deviceName = intent.getStringExtra(EXTRA_DEVICE_NAME); for (int i = 0, l = mDevices.size(); i < l; i++) { String name = null; try { name = mDevices.get(i).getString(KEY_NAME); } catch (JSONException e1) { e1.printStackTrace(); } if ((name != null) && name.equals(deviceName)) { JSONObject deviceJObj = mDevices.remove(i); JSONArray widgetsJArr; if (deviceJObj.has(KEY_WIDGETS)) { try { widgetsJArr = deviceJObj.getJSONArray(KEY_WIDGETS); } catch (JSONException e) { widgetsJArr = new JSONArray(); } } else widgetsJArr = new JSONArray(); widgetsJArr.put(appWidgetId); try { deviceJObj.put(KEY_WIDGETS, widgetsJArr); } catch (JSONException e) { e.printStackTrace(); } mDevices.add(i, deviceJObj); TapLock.storeDevices(this, getSharedPreferences(KEY_PREFS, MODE_PRIVATE), mDevices); break; } } } buildWidget(appWidgetId); } else if (intent.hasExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS)) { int[] appWidgetIds = intent.getIntArrayExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS); if (appWidgetIds != null) { for (int appWidgetId : appWidgetIds) buildWidget(appWidgetId); } } } else if (AppWidgetManager.ACTION_APPWIDGET_DELETED.equals(action)) { int appWidgetId = intent.getExtras().getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID); Log.d(TAG, "delete appWidgetId: " + appWidgetId); for (int i = 0, l = mDevices.size(); i < l; i++) { JSONObject deviceJObj = mDevices.get(i); if (deviceJObj.has(KEY_WIDGETS)) { JSONArray widgetsJArr = null; try { widgetsJArr = deviceJObj.getJSONArray(KEY_WIDGETS); } catch (JSONException e) { e.printStackTrace(); } if (widgetsJArr != null) { boolean wasUpdated = false; JSONArray newWidgetsJArr = new JSONArray(); for (int widgetIdx = 0, wdigetsLen = widgetsJArr .length(); widgetIdx < wdigetsLen; widgetIdx++) { int widgetId; try { widgetId = widgetsJArr.getInt(widgetIdx); } catch (JSONException e) { widgetId = AppWidgetManager.INVALID_APPWIDGET_ID; e.printStackTrace(); } Log.d(TAG, "eval widgetId: " + widgetId); if ((widgetId != AppWidgetManager.INVALID_APPWIDGET_ID) && (widgetId == appWidgetId)) { Log.d(TAG, "skip: " + widgetId); wasUpdated = true; } else { Log.d(TAG, "include: " + widgetId); newWidgetsJArr.put(widgetId); } } if (wasUpdated) { try { deviceJObj.put(KEY_WIDGETS, newWidgetsJArr); mDevices.remove(i); mDevices.add(i, deviceJObj); TapLock.storeDevices(this, getSharedPreferences(KEY_PREFS, MODE_PRIVATE), mDevices); Log.d(TAG, "stored: " + deviceJObj.toString()); } catch (JSONException e) { e.printStackTrace(); } } } } else { JSONArray widgetsJArr = new JSONArray(); try { deviceJObj.put(KEY_WIDGETS, widgetsJArr); mDevices.remove(i); mDevices.add(i, deviceJObj); TapLock.storeDevices(this, getSharedPreferences(KEY_PREFS, MODE_PRIVATE), mDevices); } catch (JSONException e) { e.printStackTrace(); } } } } } return START_STICKY; }
From source file:com.limewoodmedia.nsdroid.services.UpdateService.java
@Override protected void onHandleIntent(Intent intent) { // Check/*from w w w . ja v a2 s .c om*/ Log.d(TAG, "Checking for update for: " + intent.getStringExtra("update")); // Check for Internet connection final ConnectivityManager conMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); final NetworkInfo activeNetwork = conMgr.getActiveNetworkInfo(); if (activeNetwork == null || !activeNetwork.isConnected()) { Log.d(TAG, "No network connection"); return; } boolean showNotification = false; SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); // Check a shard for updates if (intent.getStringExtra("API").equalsIgnoreCase("region")) { // Check region shards RegionData rData; if (intent.getStringExtra("region").equalsIgnoreCase("-1")) { if (intent.getStringExtra("shard").equalsIgnoreCase("messages")) { // Check for new messages try { rData = API.getInstance(this).getRegionInfo(NationInfo.getInstance(this).getRegionId(), RegionData.Shards.MESSAGES); } catch (RateLimitReachedException e) { e.printStackTrace(); return; } catch (UnknownRegionException e) { e.printStackTrace(); return; } catch (XmlPullParserException e) { e.printStackTrace(); return; } catch (IOException e) { e.printStackTrace(); return; } if (rData.messages != null && rData.messages.size() > 0) { RMBMessage msg = rData.messages.get(rData.messages.size() - 1); long lastTS = prefs.getLong("update_region_messages_timestamp", -1); String lastNation = prefs.getString("update_region_messages_nation", ""); if (lastTS != msg.timestamp && lastNation.compareToIgnoreCase(msg.message) != 0) { // There are new messages Log.d(TAG, "New messages!"); if (Region.shouldUpdate || NSDroid.shouldUpdate) { // Send broadcast to update RMB directly Intent i = new Intent(NotificationsHelper.RMB_UPDATE_ACTION); RMBMessageParcelable[] parcel = new RMBMessageParcelable[rData.messages.size()]; int t = 0; for (RMBMessage m : rData.messages) { parcel[t] = new RMBMessageParcelable(m); t++; } i.putExtra("com.limewoodMedia.nsdroid.holders.RMBMessageParcelable", parcel); sendBroadcast(i); if (NSDroid.shouldUpdate) { showNotification = true; } } else { // Not currently showing showNotification = true; } } else { // No new messages - set new alarm NotificationsHelper.setAlarmForRMB(this, Integer.parseInt(prefs.getString("rmb_update_interval", "-1"))); } } } } } else if (intent.getStringExtra("API").equalsIgnoreCase("issues")) { // Issues IssuesInfo issues = API.getInstance(this).getIssues(); Log.d(TAG, "Issues: " + issues); if (issues != null) { if (issues.issues != null && issues.issues.size() > 0) { Log.d(TAG, "Issues: " + issues.issues.size()); intent.putExtra("notification_number", issues.issues.size()); showNotification = true; } if (issues.nextIssue != null) { Log.d(TAG, "Issues: " + issues.nextIssue); NotificationsHelper.setIssuesTimer(this, issues.nextIssue); } } } if (showNotification) { // Show notification icon Intent i; try { // Start activity with class name i = new Intent(this, Class.forName(intent.getStringExtra("class"))); if (intent.hasExtra("page")) { i.putExtra("page", intent.getIntExtra("page", 0)); } Log.d(TAG, "Build notification to update " + intent.getStringExtra("class")); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); PendingIntent pi = PendingIntent.getActivity(this, intent.getIntExtra("notification_id", NOTIFICATION_ID), i, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Builder notifyBuilder = new NotificationCompat.Builder(this) .setContentTitle(getResources() .getString(intent.getIntExtra("notification_title", R.string.notification_title))) .setContentText(getResources() .getString(intent.getIntExtra("notification_text", R.string.notification_text))) .setSmallIcon(R.drawable.app_icon).setAutoCancel(true).setContentIntent(pi) .setOnlyAlertOnce(false).setWhen(System.currentTimeMillis()); if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean("notify_sound", true) && intent.hasExtra("notification_sound")) { notifyBuilder.setSound(Uri.parse("android.resource://" + getPackageName() + "/" + intent.getIntExtra("notification_sound", -1))); } if (intent.hasExtra("notification_number")) { notifyBuilder.setNumber(intent.getIntExtra("notification_number", 0)).setShowWhen(false); } Log.d(TAG, "Show notification"); notificationManager.notify(intent.getIntExtra("notification_id", NOTIFICATION_ID), notifyBuilder.getNotification()); } catch (ClassNotFoundException e) { e.printStackTrace(); } } }
From source file:com.mozilla.SUTAgentAndroid.service.DoCommand.java
public String StrtUpdtOMatic(String sPkgName, String sPkgFileName, String sCallBackIP, String sCallBackPort) { String sRet = ""; Context ctx = contextWrapper.getApplicationContext(); PackageManager pm = ctx.getPackageManager(); Intent prgIntent = new Intent(); prgIntent.setPackage("com.mozilla.watcher"); try {/* w ww . jav a 2 s .c om*/ PackageInfo pi = pm.getPackageInfo("com.mozilla.watcher", PackageManager.GET_SERVICES | PackageManager.GET_INTENT_FILTERS); ServiceInfo[] si = pi.services; for (int i = 0; i < si.length; i++) { ServiceInfo s = si[i]; if (s.name.length() > 0) { prgIntent.setClassName(s.packageName, s.name); break; } } } catch (NameNotFoundException e) { e.printStackTrace(); sRet = sErrorPrefix + "watcher is not properly installed"; return (sRet); } prgIntent.putExtra("command", "updt"); prgIntent.putExtra("pkgName", sPkgName); prgIntent.putExtra("pkgFile", sPkgFileName); prgIntent.putExtra("reboot", true); try { if ((sCallBackIP != null) && (sCallBackPort != null) && (sCallBackIP.length() > 0) && (sCallBackPort.length() > 0)) { FileOutputStream fos = ctx.openFileOutput("update.info", Context.MODE_WORLD_READABLE | Context.MODE_WORLD_WRITEABLE); String sBuffer = sCallBackIP + "," + sCallBackPort + "\rupdate started " + sPkgName + " " + sPkgFileName + "\r"; fos.write(sBuffer.getBytes()); fos.flush(); fos.close(); fos = null; prgIntent.putExtra("outFile", ctx.getFilesDir() + "/update.info"); } else { if (prgIntent.hasExtra("outFile")) { System.out.println("outFile extra unset from intent"); prgIntent.removeExtra("outFile"); } } ComponentName cn = contextWrapper.startService(prgIntent); if (cn != null) sRet = "exit"; else sRet = sErrorPrefix + "Unable to use watcher service"; } catch (ActivityNotFoundException anf) { sRet = sErrorPrefix + "Activity Not Found Exception [updt] call failed"; anf.printStackTrace(); } catch (FileNotFoundException e) { sRet = sErrorPrefix + "File creation error [updt] call failed"; e.printStackTrace(); } catch (IOException e) { sRet = sErrorPrefix + "File error [updt] call failed"; e.printStackTrace(); } ctx = null; return (sRet); }
From source file:com.irccloud.android.activity.MainActivity.java
private void setFromIntent(Intent intent) { launchBid = -1;//from www. java 2s .c om launchURI = null; if (NetworkConnection.getInstance().ready) setIntent(new Intent(this, MainActivity.class)); if (intent.hasExtra("bid")) { int new_bid = intent.getIntExtra("bid", 0); if (NetworkConnection.getInstance().ready && NetworkConnection.getInstance().getState() == NetworkConnection.STATE_CONNECTED && BuffersDataSource.getInstance().getBuffer(new_bid) == null) { Crashlytics.log(Log.WARN, "IRCCloud", "Invalid bid requested by launch intent: " + new_bid); Notifications.getInstance().deleteNotificationsForBid(new_bid); if (excludeBIDTask != null) excludeBIDTask.cancel(true); excludeBIDTask = new ExcludeBIDTask(); excludeBIDTask.execute(new_bid); return; } else if (BuffersDataSource.getInstance().getBuffer(new_bid) != null) { Crashlytics.log(Log.DEBUG, "IRCCloud", "Found BID, switching buffers"); if (buffer != null && buffer.bid != new_bid) backStack.add(0, buffer.bid); buffer = BuffersDataSource.getInstance().getBuffer(new_bid); server = ServersDataSource.getInstance().getServer(buffer.cid); } else { Crashlytics.log(Log.DEBUG, "IRCCloud", "BID not found, will try after reconnecting"); launchBid = new_bid; } } if (intent.getData() != null && intent.getData().getScheme() != null && intent.getData().getScheme().startsWith("irc")) { if (open_uri(intent.getData())) { return; } else { launchURI = intent.getData(); buffer = null; server = null; } } else if (intent.hasExtra("cid")) { if (buffer == null) { buffer = BuffersDataSource.getInstance().getBufferByName(intent.getIntExtra("cid", 0), intent.getStringExtra("name")); if (buffer != null) { server = ServersDataSource.getInstance().getServer(intent.getIntExtra("cid", 0)); } } } if (buffer == null) { server = null; } else { if (intent.hasExtra(Intent.EXTRA_STREAM)) { String type = getContentResolver().getType((Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM)); if (type != null && type.startsWith("image/") && (!NetworkConnection.getInstance().uploadsAvailable() || PreferenceManager.getDefaultSharedPreferences(this) .getString("image_service", "IRCCloud").equals("imgur"))) { new ImgurRefreshTask((Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM)).execute((Void) null); } else { fileUploadTask = new FileUploadTask((Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM), this); fileUploadTask.execute((Void) null); } } if (intent.hasExtra(Intent.EXTRA_TEXT)) { if (intent.hasExtra(Intent.EXTRA_SUBJECT)) buffer.draft = intent.getStringExtra(Intent.EXTRA_SUBJECT) + " (" + intent.getStringExtra(Intent.EXTRA_TEXT) + ")"; else buffer.draft = intent.getStringExtra(Intent.EXTRA_TEXT); } } if (buffer == null) { launchBid = intent.getIntExtra("bid", -1); } else { onBufferSelected(buffer.bid); } }
From source file:com.klinker.android.launcher.launcher3.Launcher.java
private boolean startActivity(View v, Intent intent, Object tag) { intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); try {/* w ww . j a va2 s . c om*/ // Only launch using the new animation if the shortcut has not opted out (this is a // private contract between launcher and may be ignored in the future). boolean useLaunchAnimation = (v != null) && !intent.hasExtra(INTENT_EXTRA_IGNORE_LAUNCH_ANIMATION); LauncherAppsCompat launcherApps = LauncherAppsCompat.getInstance(this); UserManagerCompat userManager = UserManagerCompat.getInstance(this); UserHandleCompat user = null; if (intent.hasExtra(AppInfo.EXTRA_PROFILE)) { long serialNumber = intent.getLongExtra(AppInfo.EXTRA_PROFILE, -1); user = userManager.getUserForSerialNumber(serialNumber); } Bundle optsBundle = null; if (useLaunchAnimation) { ActivityOptions opts = null; if (sClipRevealMethod != null) { // TODO: call method directly when Launcher3 can depend on M APIs int left = 0, top = 0; int width = v.getMeasuredWidth(), height = v.getMeasuredHeight(); if (v instanceof TextView) { // Launch from center of icon, not entire view Drawable icon = Workspace.getTextViewIcon((TextView) v); if (icon != null) { Rect bounds = icon.getBounds(); left = (width - bounds.width()) / 2; top = v.getPaddingTop(); width = bounds.width(); height = bounds.height(); } } try { opts = (ActivityOptions) sClipRevealMethod.invoke(null, v, left, top, width, height); } catch (IllegalAccessException e) { Log.d(TAG, "Could not call makeClipRevealAnimation: " + e); sClipRevealMethod = null; } catch (InvocationTargetException e) { Log.d(TAG, "Could not call makeClipRevealAnimation: " + e); sClipRevealMethod = null; } } if (opts == null && !Utilities.isLmpOrAbove()) { // Below L, we use a scale up animation opts = ActivityOptions.makeScaleUpAnimation(v, 0, 0, v.getMeasuredWidth(), v.getMeasuredHeight()); } else if (opts == null && Utilities.isLmpMR1()) { // On L devices, we use the device default slide-up transition. // On L MR1 devices, we a custom version of the slide-up transition which // doesn't have the delay present in the device default. opts = ActivityOptions.makeCustomAnimation(this, R.anim.task_open_enter, R.anim.no_anim); } optsBundle = opts != null ? opts.toBundle() : null; } if (user == null || user.equals(UserHandleCompat.myUserHandle())) { // Could be launching some bookkeeping activity startActivity(intent, optsBundle); } else { // TODO Component can be null when shortcuts are supported for secondary user launcherApps.startActivityForProfile(intent.getComponent(), user, intent.getSourceBounds(), optsBundle); } return true; } catch (SecurityException e) { Toast.makeText(this, R.string.activity_not_found, Toast.LENGTH_SHORT).show(); Log.e(TAG, "Launcher does not have the permission to launch " + intent + ". Make sure to create a MAIN intent-filter for the corresponding activity " + "or use the exported attribute for this activity. " + "tag=" + tag + " intent=" + intent, e); } return false; }
From source file:com.android.soma.Launcher.java
boolean startActivity(View v, Intent intent, Object tag) { intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); try {//from w w w. j av a2 s. co m // Only launch using the new animation if the shortcut has not opted out (this is a // private contract between launcher and may be ignored in the future). boolean useLaunchAnimation = (v != null) && !intent.hasExtra(INTENT_EXTRA_IGNORE_LAUNCH_ANIMATION); if (useLaunchAnimation) { ActivityOptions opts = ActivityOptions.makeScaleUpAnimation(v, 0, 0, v.getMeasuredWidth(), v.getMeasuredHeight()); startActivity(intent, opts.toBundle()); } else { startActivity(intent); } return true; } catch (SecurityException e) { Toast.makeText(this, R.string.activity_not_found, Toast.LENGTH_SHORT).show(); Log.e(TAG, "Launcher does not have the permission to launch " + intent + ". Make sure to create a MAIN intent-filter for the corresponding activity " + "or use the exported attribute for this activity. " + "tag=" + tag + " intent=" + intent, e); } return false; }
From source file:com.android.launcher3.Launcher.java
public boolean startActivitySafely(View v, Intent intent, ItemInfo item) { if (mIsSafeModeEnabled && !Utilities.isSystemApp(this, intent)) { Toast.makeText(this, R.string.safemode_shortcut_error, Toast.LENGTH_SHORT).show(); return false; }//from w ww . j a v a 2 s . com // Only launch using the new animation if the shortcut has not opted out (this is a // private contract between launcher and may be ignored in the future). boolean useLaunchAnimation = (v != null) && !intent.hasExtra(INTENT_EXTRA_IGNORE_LAUNCH_ANIMATION); Bundle optsBundle = useLaunchAnimation ? getActivityLaunchOptions(v) : null; UserHandleCompat user = null; if (intent.hasExtra(AppInfo.EXTRA_PROFILE)) { long serialNumber = intent.getLongExtra(AppInfo.EXTRA_PROFILE, -1); user = UserManagerCompat.getInstance(this).getUserForSerialNumber(serialNumber); } // Prepare intent intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); if (v != null) { intent.setSourceBounds(getViewBounds(v)); } try { if (Utilities.ATLEAST_MARSHMALLOW && item != null && (item.itemType == Favorites.ITEM_TYPE_SHORTCUT || item.itemType == Favorites.ITEM_TYPE_DEEP_SHORTCUT) && ((ShortcutInfo) item).promisedIntent == null) { // Shortcuts need some special checks due to legacy reasons. startShortcutIntentSafely(intent, optsBundle, item); } else if (user == null || user.equals(UserHandleCompat.myUserHandle())) { // Could be launching some bookkeeping activity startActivity(intent, optsBundle); if (isAllAppsVisible()) { predictiveAppsProvider.updateComponentCount(intent.getComponent()); } } else { LauncherAppsCompat.getInstance(this).startActivityForProfile(intent.getComponent(), user, intent.getSourceBounds(), optsBundle); } return true; } catch (ActivityNotFoundException | SecurityException e) { Toast.makeText(this, R.string.activity_not_found, Toast.LENGTH_SHORT).show(); Log.e(TAG, "Unable to launch. tag=" + item + " intent=" + intent, e); } return false; }
From source file:com.android.mail.compose.ComposeActivity.java
/** * Fill all the widgets with the content found in the Intent Extra, if any. * Also apply the same style to all widgets. Note: if initFromExtras is * called as a result of switching between reply, reply all, and forward per * the latest revision of Gmail, and the user has already made changes to * attachments on a previous incarnation of the message (as a reply, reply * all, or forward), the original attachments from the message will not be * re-instantiated. The user's changes will be respected. This follows the * web gmail interaction.//from w w w . j av a 2 s . c om * @return {@code true} if the activity should not call {@link #finishSetup}. */ public boolean initFromExtras(Intent intent) { // If we were invoked with a SENDTO intent, the value // should take precedence final Uri dataUri = intent.getData(); if (dataUri != null) { if (MAIL_TO.equals(dataUri.getScheme())) { initFromMailTo(dataUri.toString()); } else { if (!mAccount.composeIntentUri.equals(dataUri)) { String toText = dataUri.getSchemeSpecificPart(); if (toText != null) { mTo.setText(""); addToAddresses(Arrays.asList(TextUtils.split(toText, ","))); } } } } String[] extraStrings = intent.getStringArrayExtra(Intent.EXTRA_EMAIL); if (extraStrings != null) { addToAddresses(Arrays.asList(extraStrings)); } extraStrings = intent.getStringArrayExtra(Intent.EXTRA_CC); if (extraStrings != null) { addCcAddresses(Arrays.asList(extraStrings), null); } extraStrings = intent.getStringArrayExtra(Intent.EXTRA_BCC); if (extraStrings != null) { addBccAddresses(Arrays.asList(extraStrings)); } String extraString = intent.getStringExtra(Intent.EXTRA_SUBJECT); if (extraString != null) { mSubject.setText(extraString); } for (String extra : ALL_EXTRAS) { if (intent.hasExtra(extra)) { String value = intent.getStringExtra(extra); if (EXTRA_TO.equals(extra)) { addToAddresses(Arrays.asList(TextUtils.split(value, ","))); } else if (EXTRA_CC.equals(extra)) { addCcAddresses(Arrays.asList(TextUtils.split(value, ",")), null); } else if (EXTRA_BCC.equals(extra)) { addBccAddresses(Arrays.asList(TextUtils.split(value, ","))); } else if (EXTRA_SUBJECT.equals(extra)) { mSubject.setText(value); } else if (EXTRA_BODY.equals(extra)) { setBody(value, true /* with signature */); } else if (EXTRA_QUOTED_TEXT.equals(extra)) { initQuotedText(value, true /* shouldQuoteText */); } } } Bundle extras = intent.getExtras(); if (extras != null) { CharSequence text = extras.getCharSequence(Intent.EXTRA_TEXT); setBody((text != null) ? text : "", true /* with signature */); // TODO - support EXTRA_HTML_TEXT } mExtraValues = intent.getParcelableExtra(EXTRA_VALUES); if (mExtraValues != null) { LogUtils.d(LOG_TAG, "Launched with extra values: %s", mExtraValues.toString()); initExtraValues(mExtraValues); return true; } return false; }
From source file:com.cognizant.trumobi.PersonaLauncher.java
private void completeEditShirtcut(Intent data) { if (!data.hasExtra(PersonaCustomShirtcutActivity.EXTRA_APPLICATIONINFO)) return;/*from w w w .java 2 s . c o m*/ long appInfoId = data.getLongExtra(PersonaCustomShirtcutActivity.EXTRA_APPLICATIONINFO, 0); PersonaApplicationInfo info = PersonaLauncherModel.loadApplicationInfoById(this, appInfoId); if (info != null) { Bitmap bitmap = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON); Drawable icon = null; boolean customIcon = false; ShortcutIconResource iconResource = null; if (bitmap != null) { icon = new PersonaFastBitmapDrawable(PersonaUtilities.createBitmapThumbnail(bitmap, this)); customIcon = true; } else { Parcelable extra = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE); if (extra != null && extra instanceof ShortcutIconResource) { try { iconResource = (ShortcutIconResource) extra; final PackageManager packageManager = getPackageManager(); Resources resources = packageManager.getResourcesForApplication(iconResource.packageName); final int id = resources.getIdentifier(iconResource.resourceName, null, null); icon = resources.getDrawable(id); } catch (Exception e) { PersonaLog.w(LOG_TAG, "Could not load shortcut icon: " + extra); } } } if (icon != null) { info.icon = icon; info.customIcon = customIcon; info.iconResource = iconResource; } info.itemType = PersonaLauncherSettings.Favorites.ITEM_TYPE_SHORTCUT; info.title = data.getStringExtra(Intent.EXTRA_SHORTCUT_NAME); info.intent = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_INTENT); PersonaLauncherModel.updateItemInDatabase(this, info); if (info.container == PersonaLauncherSettings.Favorites.CONTAINER_MAB) mHandleView.UpdateLaunchInfo(info); else if (info.container == PersonaLauncherSettings.Favorites.CONTAINER_LAB) mLAB.UpdateLaunchInfo(info); else if (info.container == PersonaLauncherSettings.Favorites.CONTAINER_LAB2) mLAB2.UpdateLaunchInfo(info); else if (info.container == PersonaLauncherSettings.Favorites.CONTAINER_RAB) mRAB.UpdateLaunchInfo(info); else if (info.container == PersonaLauncherSettings.Favorites.CONTAINER_RAB2) mRAB2.UpdateLaunchInfo(info); mWorkspace.updateShortcutFromApplicationInfo(info); } }
From source file:com.tct.mail.ui.AbstractActivityController.java
/** * Initialize the action bar. This is not visible to OnePaneController and * TwoPaneController so they cannot override this behavior. *///w ww.j a v a 2s. c o m protected void initializeActionBar() { final ActionBar actionBar = mActivity.getSupportActionBar(); if (actionBar == null) { return; } Intent intent = mActivity.getIntent(); /// TCT: Action is search but no extra account means a global search final boolean isSearch = intent != null && Intent.ACTION_SEARCH.equals(intent.getAction()) && intent.hasExtra(Utils.EXTRA_ACCOUNT); mActionBarController = isSearch ? new SearchActionBarController(mContext) : new ActionBarController(mContext); mActionBarController.initialize(mActivity, this, actionBar); // init the action bar to allow the 'up' affordance. // any configurations that disallow 'up' should do that later. mActionBarController.setBackButton(); }