Java Code Examples for android.content.Intent#getBundleExtra()
The following examples show how to use
android.content.Intent#getBundleExtra() .
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: easygoogle File: MessageSenderService.java License: Apache License 2.0 | 6 votes |
@Override protected void onHandleIntent(Intent intent) { if (intent != null) { String senderEmail = getSenderEmail(intent.getStringExtra(MessagingFragment.SENDER_ID_ARG)); Bundle data = intent.getBundleExtra(MessagingFragment.MESSAGE_ARG); String id = Integer.toString(sMessageId.incrementAndGet()); Log.d(TAG, "Sending gcm message:" + senderEmail + ":" + data + ":" + id); try { GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this); gcm.send(senderEmail, id, data); Log.d(TAG, "Sent!"); } catch (IOException e) { Log.e(TAG, "Failed to send GCM Message.", e); } } }
Example 2
Source Project: ncalc File: ModuleActivity.java License: GNU General Public License v3.0 | 6 votes |
private void getIntentData() { Intent intent = getIntent(); Bundle bundle = intent.getBundleExtra(BasicCalculatorActivity.DATA); if (bundle != null) { try { String num1 = bundle.getString("num1"); mInputFormula.setText(num1); String num2 = bundle.getString("num2"); if (num2 == null) return; mInputFormula2.setText(num2); isDataNull = false; clickEvaluate(); } catch (Exception e) { e.printStackTrace(); } } }
Example 3
Source Project: FacebookImageShareIntent File: AppLinkData.java License: MIT License | 6 votes |
private static AppLinkData createFromAlApplinkData(Intent intent) { Bundle applinks = intent.getBundleExtra(BUNDLE_AL_APPLINK_DATA_KEY); if (applinks == null) { return null; } AppLinkData appLinkData = new AppLinkData(); appLinkData.targetUri = intent.getData(); if (appLinkData.targetUri == null) { String targetUriString = applinks.getString(METHOD_ARGS_TARGET_URL_KEY); if (targetUriString != null) { appLinkData.targetUri = Uri.parse(targetUriString); } } appLinkData.argumentBundle = applinks; appLinkData.arguments = null; Bundle refererData = applinks.getBundle(ARGUMENTS_REFERER_DATA_KEY); if (refererData != null) { appLinkData.ref = refererData.getString(REFERER_DATA_REF_KEY); } return appLinkData; }
Example 4
Source Project: FairEmail File: FragmentPop.java License: GNU General Public License v3.0 | 6 votes |
@Override public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { super.onActivityResult(requestCode, resultCode, data); try { switch (requestCode) { case REQUEST_COLOR: if (resultCode == RESULT_OK && data != null) { if (ActivityBilling.isPro(getContext())) { Bundle args = data.getBundleExtra("args"); btnColor.setColor(args.getInt("color")); } else startActivity(new Intent(getContext(), ActivityBilling.class)); } break; case REQUEST_DELETE: if (resultCode == RESULT_OK) onDelete(); break; } } catch (Throwable ex) { Log.e(ex); } }
Example 5
Source Project: android-AppRestrictions File: GetRestrictionsReceiver.java License: Apache License 2.0 | 6 votes |
@Override public void onReceive(final Context context, Intent intent) { final PendingResult result = goAsync(); // If app restriction settings are already created, they will be included in the Bundle // as key/value pairs. final Bundle existingRestrictions = intent.getBundleExtra(Intent.EXTRA_RESTRICTIONS_BUNDLE); Log.i(TAG, "existingRestrictions = " + existingRestrictions); new Thread() { public void run() { createRestrictions(context, result, existingRestrictions); } }.start(); }
Example 6
Source Project: AlbumCameraRecorder File: CameraFragment.java License: MIT License | 5 votes |
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode != RESULT_OK) return; switch (requestCode) { case REQUEST_CODE_PREVIEW_CAMRRA: // 如果在预览界面点击了确定 if (data.getBooleanExtra(BasePreviewActivity.EXTRA_RESULT_APPLY, false)) { // 请求的预览界面 Bundle resultBundle = data.getBundleExtra(BasePreviewActivity.EXTRA_RESULT_BUNDLE); // 获取选择的数据 ArrayList<MultiMedia> selected = resultBundle.getParcelableArrayList(SelectedItemCollection.STATE_SELECTION); if (selected == null) return; // 循环判断,如果不存在,则删除 ListIterator<Map.Entry<Integer, BitmapData>> i = new ArrayList<>(mCameraLayout.mCaptureBitmaps.entrySet()).listIterator(mCameraLayout.mCaptureBitmaps.size()); while (i.hasPrevious()) { Map.Entry<Integer, BitmapData> entry = i.previous(); int k = 0; for (MultiMedia multiMedia : selected) { if (!entry.getValue().getUri().toString().equals(multiMedia.getUri().toString())) { k++; } } if (k == selected.size()) { // 所有都不符合,则删除 mCameraLayout.removePosition(entry.getKey()); } } } break; } }
Example 7
Source Project: ncalc File: FactorExpressionActivity.java License: GNU General Public License v3.0 | 5 votes |
/** * get data from activity start it */ private void getIntentData() { Intent intent = getIntent(); Bundle bundle = intent.getBundleExtra(BasicCalculatorActivity.DATA); if (bundle != null) { String data = bundle.getString(BasicCalculatorActivity.DATA); if (data != null) { data = new ExpressionTokenizer().getNormalExpression(data); mInputFormula.setText(data); isDataNull = false; clickEvaluate(); } } }
Example 8
Source Project: android-popular-movies-app File: DetailActivity.java License: Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mDetailBinding = DataBindingUtil.setContentView(this, R.layout.activity_detail); // Get the movie data from the MainActivity. The movie data includes the movie id, original title, // title, poster path, overview, vote average, release date, and backdrop path. Intent intent = getIntent(); if (intent != null) { if (intent.hasExtra(EXTRA_MOVIE)) { Bundle b = intent.getBundleExtra(EXTRA_MOVIE); mMovie = b.getParcelable(EXTRA_MOVIE); } } // Get the MovieDatabase instance mDb = MovieDatabase.getInstance(getApplicationContext()); // Check if the movie is in the favorites collection or not mIsInFavorites = isInFavoritesCollection(); // Setup the UI setupUI(); if (savedInstanceState != null) { mDetailBinding.pbDetailLoadingIndicator.setVisibility(View.GONE); String resultRuntime = savedInstanceState.getString(RESULTS_RUNTIME); String resultReleaseYear = savedInstanceState.getString(RESULTS_RELEASE_YEAR); String resultGenre = savedInstanceState.getString(RESULTS_GENRE); mDetailBinding.tvRuntime.setText(resultRuntime); mDetailBinding.tvReleaseYear.setText(resultReleaseYear); mDetailBinding.tvGenre.setText(resultGenre); } }
Example 9
Source Project: 365browser File: IntentUtils.java License: Apache License 2.0 | 5 votes |
/** * Just like {@link Intent#getBundleExtra(String)} but doesn't throw exceptions. */ public static Bundle safeGetBundleExtra(Intent intent, String name) { try { return intent.getBundleExtra(name); } catch (Throwable t) { // Catches un-parceling exceptions. Log.e(TAG, "getBundleExtra failed on intent " + intent); return null; } }
Example 10
Source Project: kognitivo File: NativeProtocol.java License: Apache License 2.0 | 5 votes |
public static Bundle getMethodArgumentsFromIntent(Intent intent) { int version = getProtocolVersionFromIntent(intent); if (!isVersionCompatibleWithBucketedIntent(version)) { return intent.getExtras(); } return intent.getBundleExtra(EXTRA_PROTOCOL_METHOD_ARGS); }
Example 11
Source Project: android-job File: PlatformAlarmReceiver.java License: Apache License 2.0 | 5 votes |
@Override public void onReceive(Context context, Intent intent) { if (intent != null && intent.hasExtra(EXTRA_JOB_ID) && intent.hasExtra(EXTRA_JOB_EXACT)) { int jobId = intent.getIntExtra(EXTRA_JOB_ID, -1); Bundle transientExtras = intent.getBundleExtra(EXTRA_TRANSIENT_EXTRAS); if (intent.getBooleanExtra(EXTRA_JOB_EXACT, false)) { Intent serviceIntent = PlatformAlarmServiceExact.createIntent(context, jobId, transientExtras); JobProxy.Common.startWakefulService(context, serviceIntent); } else { PlatformAlarmService.start(context, jobId, transientExtras); } } }
Example 12
Source Project: delion File: IntentUtils.java License: Apache License 2.0 | 5 votes |
/** * Just like {@link Intent#getBundleExtra(String)} but doesn't throw exceptions. */ public static Bundle safeGetBundleExtra(Intent intent, String name) { try { return intent.getBundleExtra(name); } catch (Throwable t) { // Catches un-parceling exceptions. Log.e(TAG, "getBundleExtra failed on intent " + intent); return null; } }
Example 13
Source Project: Cangol-appcore File: DynamicActivity.java License: Apache License 2.0 | 5 votes |
protected void handleIntent(Intent intent) { Uri data = intent.getData(); if(data!=null){ Log.i("data="+data+",host="+data.getHost()+",path="+data.getPath()); }else{ String className = intent.getStringExtra("class"); Bundle bundle = intent.getBundleExtra("args"); try { toFragment(Class.forName(className), bundle); } catch (ClassNotFoundException e) { e.printStackTrace(); } } }
Example 14
Source Project: kernel_adiutor File: RunProfileReceiver.java License: Apache License 2.0 | 5 votes |
@Override public void onReceive(Context context, Intent intent) { if (!ACTION_FIRE_SETTING.equals(intent.getAction()) || !RootUtils.rootAccess() || !RootUtils.hasAppletSupport()) return; RootUtils.closeSU(); BundleScrubber.scrub(intent); final Bundle bundle = intent.getBundleExtra(AddProfileActivity.EXTRA_BUNDLE); BundleScrubber.scrub(bundle); if (PluginBundleManager.isBundleValid(bundle)) { String commands = bundle.getString(PluginBundleManager.BUNDLE_EXTRA_STRING_MESSAGE); if (commands != null) { String[] cs = commands.split(AddProfileActivity.DIVIDER); Log.i(Constants.TAG + ": " + getClass().getSimpleName(), "Applying " + cs[0]); Utils.toast(context.getString(R.string.applying_profile, cs[0]), context, Toast.LENGTH_LONG); if (cs.length > 1) { RootUtils.SU su = new RootUtils.SU(); for (int i = 1; i < cs.length; i++) { Log.i(Constants.TAG + ": " + getClass().getSimpleName(), "Run: " + cs[i]); su.runCommand(cs[i]); } su.close(); } } } }
Example 15
Source Project: LogcatViewer File: StandOutWindow.java License: GNU General Public License v3.0 | 4 votes |
@Override public int onStartCommand(Intent intent, int flags, int startId) { super.onStartCommand(intent, flags, startId); // intent should be created with // getShowIntent(), getHideIntent(), getCloseIntent() if (intent != null) { String action = intent.getAction(); int id = intent.getIntExtra("id", DEFAULT_ID); // this will interfere with getPersistentNotification() if (id == ONGOING_NOTIFICATION_ID) { throw new RuntimeException( "ID cannot equals StandOutWindow.ONGOING_NOTIFICATION_ID"); } if (ACTION_SHOW.equals(action) || ACTION_RESTORE.equals(action)) { show(id); } else if (ACTION_HIDE.equals(action)) { hide(id); } else if (ACTION_CLOSE.equals(action)) { close(id); } else if (ACTION_CLOSE_ALL.equals(action)) { closeAll(); } else if (ACTION_SEND_DATA.equals(action)) { if (!isExistingId(id) && id != DISREGARD_ID) { Log.w(TAG, "Sending data to non-existant window. If this is not intended, make sure toId is either an existing window's id or DISREGARD_ID."); } Bundle data = intent.getBundleExtra("wei.mark.standout.data"); int requestCode = intent.getIntExtra("requestCode", 0); @SuppressWarnings("unchecked") Class<? extends StandOutWindow> fromCls = (Class<? extends StandOutWindow>) intent .getSerializableExtra("wei.mark.standout.fromCls"); int fromId = intent.getIntExtra("fromId", DEFAULT_ID); onReceiveData(id, requestCode, data, fromCls, fromId); } } else { Log.w(TAG, "Tried to onStartCommand() with a null intent."); } // the service is started in foreground in show() // so we don't expect Android to kill this service return START_NOT_STICKY; }
Example 16
Source Project: xDrip File: CircleWatchface.java License: GNU General Public License v3.0 | 4 votes |
@Override public void onReceive(Context context, Intent intent) { final PowerManager.WakeLock wl = JoH.getWakeLock("circle-message-receiver", 60000); try { DataMap dataMap; Bundle bundle = intent.getBundleExtra("msg"); if (bundle != null) { dataMap = DataMap.fromBundle(bundle); String msg = dataMap.getString("msg", ""); int length = dataMap.getInt("length", 0); JoH.static_toast(xdrip.getAppContext(), msg, length); } bundle = intent.getBundleExtra("steps"); if (bundle != null) { dataMap = DataMap.fromBundle(bundle); if (mTimeStepsRcvd <= dataMap.getLong("steps_timestamp", 0)) { mStepsCount = dataMap.getInt("steps", 0); mTimeStepsRcvd = dataMap.getLong("steps_timestamp", 0); } } bundle = intent.getBundleExtra("data"); if (bundle != null) { dataMap = DataMap.fromBundle(bundle); setSgvLevel((int) dataMap.getLong("sgvLevel")); Log.d(TAG, "CircleWatchface sgv level : " + getSgvLevel()); setSgvString(dataMap.getString("sgvString")); Log.d(TAG, "CircleWatchface sgv string : " + getSgvString()); setRawString(dataMap.getString("rawString")); setDelta(dataMap.getString("delta")); setDatetime(dataMap.getDouble("timestamp")); mExtraStatusLine = dataMap.getString("extra_status_line"); addToWatchSet(dataMap); //start animation? // dataMap.getDataMapArrayList("entries") == null -> not on "resend data". if (sharedPrefs.getBoolean("animation", false) && dataMap.getDataMapArrayList("entries") == null && (getSgvString().equals("100") || getSgvString().equals("5.5") || getSgvString().equals("5,5"))) { startAnimation(); } prepareLayout(); prepareDrawTime(); invalidate(); } //status bundle = intent.getBundleExtra("status"); if (bundle != null) { dataMap = DataMap.fromBundle(bundle); setStatusString(dataMap.getString("externalStatusString")); prepareLayout(); prepareDrawTime(); invalidate(); } } finally { JoH.releaseWakeLock(wl); } }
Example 17
Source Project: Study_Android_Demo File: QRCodeEncoder.java License: Apache License 2.0 | 4 votes |
private void encodeQRCodeContents(Intent intent, String type) { switch (type) { case Contents.Type.TEXT: String textData = intent.getStringExtra(Intents.Encode.DATA); if (textData != null && !textData.isEmpty()) { contents = textData; displayContents = textData; title = activity.getString(R.string.contents_text); } break; case Contents.Type.EMAIL: String emailData = ContactEncoder.trim(intent.getStringExtra(Intents.Encode.DATA)); if (emailData != null) { contents = "mailto:" + emailData; displayContents = emailData; title = activity.getString(R.string.contents_email); } break; case Contents.Type.PHONE: String phoneData = ContactEncoder.trim(intent.getStringExtra(Intents.Encode.DATA)); if (phoneData != null) { contents = "tel:" + phoneData; displayContents = PhoneNumberUtils.formatNumber(phoneData); title = activity.getString(R.string.contents_phone); } break; case Contents.Type.SMS: String smsData = ContactEncoder.trim(intent.getStringExtra(Intents.Encode.DATA)); if (smsData != null) { contents = "sms:" + smsData; displayContents = PhoneNumberUtils.formatNumber(smsData); title = activity.getString(R.string.contents_sms); } break; case Contents.Type.CONTACT: Bundle contactBundle = intent.getBundleExtra(Intents.Encode.DATA); if (contactBundle != null) { String name = contactBundle.getString(ContactsContract.Intents.Insert.NAME); String organization = contactBundle.getString(ContactsContract.Intents.Insert.COMPANY); String address = contactBundle.getString(ContactsContract.Intents.Insert.POSTAL); List<String> phones = getAllBundleValues(contactBundle, Contents.PHONE_KEYS); List<String> phoneTypes = getAllBundleValues(contactBundle, Contents.PHONE_TYPE_KEYS); List<String> emails = getAllBundleValues(contactBundle, Contents.EMAIL_KEYS); String url = contactBundle.getString(Contents.URL_KEY); List<String> urls = url == null ? null : Collections.singletonList(url); String note = contactBundle.getString(Contents.NOTE_KEY); ContactEncoder encoder = useVCard ? new VCardContactEncoder() : new MECARDContactEncoder(); String[] encoded = encoder.encode(Collections.singletonList(name), organization, Collections.singletonList(address), phones, phoneTypes, emails, urls, note); // Make sure we've encoded at least one field. if (!encoded[1].isEmpty()) { contents = encoded[0]; displayContents = encoded[1]; title = activity.getString(R.string.contents_contact); } } break; case Contents.Type.LOCATION: Bundle locationBundle = intent.getBundleExtra(Intents.Encode.DATA); if (locationBundle != null) { // These must use Bundle.getFloat(), not getDouble(), it's part of the API. float latitude = locationBundle.getFloat("LAT", Float.MAX_VALUE); float longitude = locationBundle.getFloat("LONG", Float.MAX_VALUE); if (latitude != Float.MAX_VALUE && longitude != Float.MAX_VALUE) { contents = "geo:" + latitude + ',' + longitude; displayContents = latitude + "," + longitude; title = activity.getString(R.string.contents_location); } } break; } }
Example 18
Source Project: HeadsUp File: SettingsActivity.java License: GNU General Public License v2.0 | 4 votes |
@Override protected void onCreate(Bundle savedState) { super.onCreate(savedState); // Should happen before any call to getIntent() getMetaData(); final Intent intent = getIntent(); if (intent.hasExtra(EXTRA_UI_OPTIONS)) { getWindow().setUiOptions(intent.getIntExtra(EXTRA_UI_OPTIONS, 0)); } // Getting Intent properties can only be done after the super.onCreate(...) final String initialFragmentName = intent.getStringExtra(EXTRA_SHOW_FRAGMENT); mIsShortcut = isShortCutIntent(intent) || isLikeShortCutIntent(intent) || intent.getBooleanExtra(EXTRA_SHOW_FRAGMENT_AS_SHORTCUT, false); final ComponentName cn = intent.getComponent(); final String className = cn.getClassName(); boolean isShowingDashboard = false; // className.equals(Settings2.class.getName()); // This is a "Sub Settings" when: // - this is a real SubSettings // - or :settings:show_fragment_as_subsetting is passed to the Intent final boolean isSubSettings = className.equals(SubSettings.class.getName()) || intent.getBooleanExtra(EXTRA_SHOW_FRAGMENT_AS_SUBSETTING, false); // If this is a sub settings, then apply the SubSettings Theme for the ActionBar content insets if (isSubSettings) { // Check also that we are not a Theme Dialog as we don't want to override them /* final int themeResId = getTheme(). getThemeResId(); if (themeResId != R.style.Theme_DialogWhenLarge && themeResId != R.style.Theme_SubSettingsDialogWhenLarge) { setTheme(R.style.Theme_SubSettings); } */ } setContentView(R.layout.settings_main_dashboard); mContent = (ViewGroup) findViewById(R.id.main_content); getSupportFragmentManager().addOnBackStackChangedListener(this); if (savedState != null) { // We are restarting from a previous saved state; used that to initialize, instead // of starting fresh. setTitleFromIntent(intent); ArrayList<DashboardCategory> categories = savedState.getParcelableArrayList(SAVE_KEY_CATEGORIES); if (categories != null) { mCategories.clear(); mCategories.addAll(categories); setTitleFromBackStack(); } mDisplayHomeAsUpEnabled = savedState.getBoolean(SAVE_KEY_SHOW_HOME_AS_UP); } else { if (!isShowingDashboard) { mDisplayHomeAsUpEnabled = isSubSettings; setTitleFromIntent(intent); Bundle initialArguments = intent.getBundleExtra(EXTRA_SHOW_FRAGMENT_ARGUMENTS); switchToFragment(initialFragmentName, initialArguments, true, false, mInitialTitleResId, mInitialTitle, false); } else { mDisplayHomeAsUpEnabled = false; mInitialTitleResId = R.string.app_name; switchToFragment(DashboardFragment.class.getName(), null, false, false, mInitialTitleResId, mInitialTitle, false); } } ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setDisplayHomeAsUpEnabled(mDisplayHomeAsUpEnabled); actionBar.setHomeButtonEnabled(mDisplayHomeAsUpEnabled); } }
Example 19
Source Project: letv File: NativeProtocol.java License: Apache License 2.0 | 4 votes |
public static Bundle getMethodArgumentsFromIntent(Intent intent) { if (isVersionCompatibleWithBucketedIntent(getProtocolVersionFromIntent(intent))) { return intent.getBundleExtra(EXTRA_PROTOCOL_METHOD_ARGS); } return intent.getExtras(); }
Example 20
Source Project: Android-Remote File: TaskerFireReceiver.java License: GNU General Public License v3.0 | 4 votes |
@Override public void onReceive(Context context, Intent intent) { if (com.twofortyfouram.locale.api.Intent.ACTION_FIRE_SETTING.equals(intent.getAction())) { final Bundle bundle = intent.getBundleExtra( com.twofortyfouram.locale.api.Intent.EXTRA_BUNDLE); Message msg = Message.obtain(); switch (bundle.getInt(PluginBundleManager.BUNDLE_EXTRA_INT_TYPE)) { case TaskerSettings.ACTION_CONNECT: String ip = bundle.getString(PluginBundleManager.BUNDLE_EXTRA_STRING_IP); int port = bundle.getInt(PluginBundleManager.BUNDLE_EXTRA_INT_PORT); int auth = bundle.getInt(PluginBundleManager.BUNDLE_EXTRA_INT_AUTH); // Start the background service Intent serviceIntent = new Intent(context, ClementineService.class); serviceIntent.putExtra(ClementineService.SERVICE_ID, ClementineService.SERVICE_START); serviceIntent.putExtra(ClementineService.EXTRA_STRING_IP, ip); serviceIntent.putExtra(ClementineService.EXTRA_INT_PORT, port); serviceIntent.putExtra(ClementineService.EXTRA_INT_AUTH, auth); context.startService(serviceIntent); break; case TaskerSettings.ACTION_DISCONNECT: msg.obj = ClementineMessage.getMessage(MsgType.DISCONNECT); break; case TaskerSettings.ACTION_PLAY: msg.obj = ClementineMessage.getMessage(MsgType.PLAY); break; case TaskerSettings.ACTION_PAUSE: msg.obj = ClementineMessage.getMessage(MsgType.PAUSE); break; case TaskerSettings.ACTION_PLAYPAUSE: msg.obj = ClementineMessage.getMessage(MsgType.PLAYPAUSE); break; case TaskerSettings.ACTION_NEXT: msg.obj = ClementineMessage.getMessage(MsgType.NEXT); break; case TaskerSettings.ACTION_STOP: msg.obj = ClementineMessage.getMessage(MsgType.STOP); break; } // Now send the message if (msg != null && msg.obj != null && App.ClementineConnection != null) { App.ClementineConnection.mHandler.sendMessage(msg); } } }