Java Code Examples for android.content.Intent#getParcelableExtra()
The following examples show how to use
android.content.Intent#getParcelableExtra() .
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 File: DownloadActivity.java From AndroidQuick with MIT License | 6 votes |
@Override public void onReceive(Context context, Intent intent) { if (intent.getAction().equals(MESSAGE_PROGRESS)) { Download download = intent.getParcelableExtra("download"); LogUtil.i(TAG, "download progress:"+download.getProgress()); mPbDownload.setProgress(download.getProgress()); if (download.getProgress() == 100) { mTvDownload.setText("File Download Complete"); } else { String tips = StringUtil.getDataSize(download.getCurrentFileSize()) + "/" + StringUtil.getDataSize(download.getTotalFileSize()); LogUtil.i(TAG, "download text:"+tips); mTvDownload.setText(tips); } } }
Example 2
Source File: EventBroker.java From DeviceConnect-Android with MIT License | 6 votes |
private void onServiceChangeEvent(final Intent event) { DevicePlugin plugin = findPluginForServiceChange(event); if (plugin == null) { warn("onServiceChangeEvent: plugin is not found"); return; } // network service discoveryの場合には、networkServiceのオブジェクトの中にデータが含まれる Bundle service = event.getParcelableExtra(ServiceDiscoveryProfile.PARAM_NETWORK_SERVICE); String id = service.getString(ServiceDiscoveryProfile.PARAM_ID); // サービスIDを変更 replaceServiceId(event, plugin); // 送信先のセッションを取得 List<Event> evts = EventManager.INSTANCE.getEventList( ServiceDiscoveryProfile.PROFILE_NAME, ServiceDiscoveryProfile.ATTRIBUTE_ON_SERVICE_CHANGE); for (int i = 0; i < evts.size(); i++) { Event evt = evts.get(i); // mContext.sendEvent(evt.getReceiverName(), event); } }
Example 3
Source File: ActionActivity.java From AgentWeb with Apache License 2.0 | 6 votes |
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState != null) { LogUtils.i(TAG, "savedInstanceState:" + savedInstanceState); return; } Intent intent = getIntent(); mAction = intent.getParcelableExtra(KEY_ACTION); if (mAction == null) { cancelAction(); this.finish(); return; } if (mAction.getAction() == Action.ACTION_PERMISSION) { permission(mAction); } else if (mAction.getAction() == Action.ACTION_CAMERA) { realOpenCamera(); } else if (mAction.getAction() == Action.ACTION_VIDEO){ realOpenVideo(); } else { fetchFile(mAction); } }
Example 4
Source File: ShareActivity.java From deskcon-android with GNU General Public License v3.0 | 6 votes |
private void handleSendFile(Intent intent) { Uri fileUri = (Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM); if (fileUri != null) { Log.d("FileUp: ", fileUri.toString()); String[] filepaths = new String[1]; filepaths[0] = fileUri.toString(); Intent i = new Intent(this, SendFilesService.class); i.putExtra("filepaths", filepaths); i.putExtra("host", HOST); i.putExtra("port", PORT); startService(i); } }
Example 5
Source File: EarphoneControlReceiver.java From YCAudioPlayer with Apache License 2.0 | 6 votes |
@Override public void onReceive(Context context, Intent intent) { KeyEvent event = intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT); if (event == null || event.getAction() != KeyEvent.ACTION_UP) { return; } switch (event.getKeyCode()) { case KeyEvent.KEYCODE_MEDIA_PLAY: case KeyEvent.KEYCODE_MEDIA_PAUSE: case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE: case KeyEvent.KEYCODE_HEADSETHOOK: PlayService.startCommand(context, MusicPlayAction.TYPE_START_PAUSE); break; case KeyEvent.KEYCODE_MEDIA_NEXT: PlayService.startCommand(context, MusicPlayAction.TYPE_NEXT); break; case KeyEvent.KEYCODE_MEDIA_PREVIOUS: PlayService.startCommand(context, MusicPlayAction.TYPE_PRE); break; default: break; } }
Example 6
Source File: EditAlertActivity.java From NightWatch with GNU General Public License v3.0 | 6 votes |
public void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == RESULT_OK) { Uri uri = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI); if (uri != null) { audioPath = uri.toString(); alertMp3File.setText(shortPath(audioPath)); } else { if (requestCode == CHOOSE_FILE) { Uri selectedImageUri = data.getData(); // Todo this code is very flacky. Probably need a much better understanding of how the different programs // select the file names. We might also have to // - See more at: http://blog.kerul.net/2011/12/pick-file-using-intentactiongetcontent.html#sthash.c8xtIr1Y.cx7s9nxH.dpuf //MEDIA GALLERY String selectedAudioPath = getPath(selectedImageUri); if (selectedAudioPath == null) { //OI FILE Manager selectedAudioPath = selectedImageUri.getPath(); } audioPath = selectedAudioPath; alertMp3File.setText(shortPath(audioPath)); } } } }
Example 7
Source File: DescriptorReceiver.java From BLEService with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void onReceive(Context context, Intent intent) { String deviceAddress = intent.getStringExtra(DeviceService.EXTRA_DEVICE_ADDRESS); BTServiceProfile serviceProfile = intent.getParcelableExtra(DeviceService.EXTRA_SERVICE); BTCharacteristicProfile chProfile = intent.getParcelableExtra(DeviceService.EXTRA_CHARACTERISTIC); BTDescriptorProfile chDescriptor = intent.getParcelableExtra(DeviceService.EXTRA_DESCRIPTOR); int status = intent.getIntExtra(DeviceService.EXTRA_STATUS, 0); byte[] value = intent.getByteArrayExtra(DeviceService.EXTRA_VALUE); onDescriptor(deviceAddress, serviceProfile.getService(), chProfile.getCharacteristic(), chDescriptor.getDescriptor(), chProfile.getCharacteristic().getValue(), status); }
Example 8
Source File: StubPendingReceiver.java From container with GNU General Public License v3.0 | 5 votes |
@Override public void onReceive(Context context, Intent intent) { Intent realIntent = intent.getParcelableExtra("_VA_|_intent_"); int userId = intent.getIntExtra("_VA_|_user_id_", VUserHandle.USER_ALL); if (realIntent != null) { VLog.d("IntentSender", "onReceive's realIntent =" + realIntent + ",extra=" + VLog.toString(realIntent.getExtras())); Intent newIntent = ComponentUtils.redirectBroadcastIntent(realIntent, userId); if (newIntent != null) { context.sendBroadcast(newIntent); } } }
Example 9
Source File: MentionsWeiboTimeLineFragment.java From iBeebo with GNU General Public License v3.0 | 5 votes |
@Override public void onReceive(Context context, Intent intent) { AccountBean intentAccount = intent.getParcelableExtra(BundleArgsConstants.ACCOUNT_EXTRA); final UnreadBean unreadBean = intent.getParcelableExtra(BundleArgsConstants.UNREAD_EXTRA); if (intentAccount == null || !accountBean.equals(intentAccount)) { return; } MessageListBean data = intent.getParcelableExtra(BundleArgsConstants.MENTIONS_WEIBO_EXTRA); addUnreadMessage(data); clearUnreadMentions(unreadBean); }
Example 10
Source File: WifiDirectHandler.java From WiFi-Buddy with MIT License | 5 votes |
/** * Indicates this device's configuration details have changed * Sticky Intent * @param intent */ private void handleThisDeviceChanged(Intent intent) { Log.i(TAG, "This device changed"); // Extra information from EXTRA_WIFI_P2P_DEVICE thisDevice = intent.getParcelableExtra(WifiP2pManager.EXTRA_WIFI_P2P_DEVICE); // Logs extra information from EXTRA_WIFI_P2P_DEVICE Log.i(TAG, p2pDeviceToString(thisDevice)); localBroadcastManager.sendBroadcast(new Intent(Action.DEVICE_CHANGED)); }
Example 11
Source File: BroadcastIntent.java From container with GNU General Public License v3.0 | 5 votes |
private void handleUninstallShortcutIntent(Intent intent) { Intent shortcut = intent.getParcelableExtra(Intent.EXTRA_SHORTCUT_INTENT); if (shortcut != null) { ComponentName componentName = shortcut.resolveActivity(getPM()); if (componentName != null) { Intent newShortcutIntent = new Intent(); newShortcutIntent.putExtra("_VA_|_uri_", shortcut); newShortcutIntent.setClassName(getHostPkg(), Constants.SHORTCUT_PROXY_ACTIVITY_NAME); newShortcutIntent.removeExtra(Intent.EXTRA_SHORTCUT_INTENT); intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, newShortcutIntent); } } }
Example 12
Source File: ProviderCredentialsBaseActivity.java From bitmask_android with GNU General Public License v3.0 | 5 votes |
@Override public void onReceive(Context context, Intent intent) { Log.d(TAG, "received Broadcast"); String action = intent.getAction(); if (action == null || !action.equalsIgnoreCase(BROADCAST_PROVIDER_API_EVENT)) { return; } int resultCode = intent.getIntExtra(BROADCAST_RESULT_CODE, RESULT_CANCELED); Bundle resultData = intent.getParcelableExtra(BROADCAST_RESULT_KEY); Provider handledProvider = resultData.getParcelable(PROVIDER_KEY); switch (resultCode) { case ProviderAPI.SUCCESSFUL_SIGNUP: String password = resultData.getString(CREDENTIALS_PASSWORD); String username = resultData.getString(CREDENTIALS_USERNAME); login(username, password); break; case ProviderAPI.SUCCESSFUL_LOGIN: downloadVpnCertificate(handledProvider); break; case ProviderAPI.FAILED_LOGIN: case ProviderAPI.FAILED_SIGNUP: handleReceivedErrors((Bundle) intent.getParcelableExtra(BROADCAST_RESULT_KEY)); break; case ProviderAPI.INCORRECTLY_DOWNLOADED_VPN_CERTIFICATE: // error handling takes place in MainActivity case ProviderAPI.CORRECTLY_DOWNLOADED_VPN_CERTIFICATE: successfullyFinished(handledProvider); break; } }
Example 13
Source File: NotificationOptionsActivity.java From financisto with GNU General Public License v2.0 | 5 votes |
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == PICKUP_RINGTONE && resultCode == RESULT_OK) { Uri ringtoneUri = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI); options.sound = ringtoneUri != null ? ringtoneUri.toString() : null; updateOptions(); } }
Example 14
Source File: WifiDelegate.java From wifi with MIT License | 5 votes |
@Override public void onReceive(Context context, Intent intent) { NetworkInfo info = intent.getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO); if (info.getState() == NetworkInfo.State.DISCONNECTED && willLink) { wifiManager.enableNetwork(netId, true); wifiManager.reconnect(); result.success(1); willLink = false; clearMethodCallAndResult(); } }
Example 15
Source File: WifiReceiver.java From NetworkGhost with GNU General Public License v2.0 | 4 votes |
@Override public void onReceive(Context context, Intent intent) { int wifiState = intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE, WifiManager.WIFI_STATE_UNKNOWN); String wifiStateText = "No State"; String action = intent.getAction(); if (action.equals(WifiManager.NETWORK_STATE_CHANGED_ACTION)) { WifiManager manager = (WifiManager) context .getSystemService(Context.WIFI_SERVICE); NetworkInfo networkInfo = intent .getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO); NetworkInfo.State state = networkInfo.getState(); if (state == NetworkInfo.State.DISCONNECTED) { if (manager.isWifiEnabled()) { doUpdate(context); wifiStateText = "WIFI_STATE_DISCONNECTED"; } } } switch (wifiState) { case WifiManager.WIFI_STATE_DISABLING: wifiStateText = "WIFI_STATE_DISABLING"; break; case WifiManager.WIFI_STATE_DISABLED: wifiStateText = "WIFI_STATE_DISABLED"; break; case WifiManager.WIFI_STATE_ENABLING: wifiStateText = "WIFI_STATE_ENABLING"; break; case WifiManager.WIFI_STATE_ENABLED: wifiStateText = "WIFI_STATE_ENABLED"; if (state == 1) state--; else doUpdate(context); break; case WifiManager.WIFI_STATE_UNKNOWN: wifiStateText = "WIFI_STATE_UNKNOWN"; break; default: break; } System.out.println("WIFI_recv: " + wifiStateText); }
Example 16
Source File: ProfileNotificationsActivity.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
@Override public void onActivityResultFragment(int requestCode, int resultCode, Intent data) { if (resultCode == Activity.RESULT_OK) { if (data == null) { return; } Uri ringtone = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI); String name = null; if (ringtone != null) { Ringtone rng = RingtoneManager.getRingtone(ApplicationLoader.applicationContext, ringtone); if (rng != null) { if (requestCode == 13) { if (ringtone.equals(Settings.System.DEFAULT_RINGTONE_URI)) { name = LocaleController.getString("DefaultRingtone", R.string.DefaultRingtone); } else { name = rng.getTitle(getParentActivity()); } } else { if (ringtone.equals(Settings.System.DEFAULT_NOTIFICATION_URI)) { name = LocaleController.getString("SoundDefault", R.string.SoundDefault); } else { name = rng.getTitle(getParentActivity()); } } rng.stop(); } } SharedPreferences preferences = MessagesController.getNotificationsSettings(currentAccount); SharedPreferences.Editor editor = preferences.edit(); if (requestCode == 12) { if (name != null) { editor.putString("sound_" + dialog_id, name); editor.putString("sound_path_" + dialog_id, ringtone.toString()); } else { editor.putString("sound_" + dialog_id, "NoSound"); editor.putString("sound_path_" + dialog_id, "NoSound"); } } else if (requestCode == 13) { if (name != null) { editor.putString("ringtone_" + dialog_id, name); editor.putString("ringtone_path_" + dialog_id, ringtone.toString()); } else { editor.putString("ringtone_" + dialog_id, "NoSound"); editor.putString("ringtone_path_" + dialog_id, "NoSound"); } } editor.commit(); if (adapter != null) { adapter.notifyItemChanged(requestCode == 13 ? ringtoneRow : soundRow); } } }
Example 17
Source File: OrderActivity.java From PoyntSamples with MIT License | 4 votes |
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); Log.d(TAG, "Received onActivityResult (" + requestCode + ")"); // Check which request we're responding to if (requestCode == COLLECT_PAYMENT_REQUEST) { Log.d("ORDER_ACTIVITY", "Received onActivityResult from Payment Action"); // Make sure the request was successful if (resultCode == Activity.RESULT_OK) { if (data != null) { Payment payment = data.getParcelableExtra(Intents.INTENT_EXTRAS_PAYMENT); Log.d("ORDER_ACTIVITY", "RESULT_OK"); Log.d("ORDER_ACTIVITY", String.valueOf(payment.getTransactions().size())); Transaction transaction = payment.getTransactions().get(0); if(transaction.getReceiptPhone()!=null) { Log.d("RECEIPT_PHONE", transaction.getReceiptPhone().toString()); } if( transaction.getReceiptEmailAddress()!=null) Log.d("RECEIPT_EMAIL", transaction.getReceiptEmailAddress()); if (payment != null) { //save order if (payment.getOrder() != null) { Log.d(TAG, "CURRENT_ORDER: " + currentOrder); Log.d(TAG, "PAYMENT_ORDER: " + payment.getOrder()); Order order = payment.getOrder(); order.setTransactions(Collections.singletonList(payment.getTransactions().get(0))); ClientContext clientContext = new ClientContext(); order.setContext(clientContext); resultTextView.append("RETURNED ORDER FROM PAYMENT OBJECT\n"); showOrderItems(order); // new completeOrderTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, payment.getOrder()); try { Log.d(TAG, order.toString()); // orderService.updateOrder(order.getId().toString(), order, UUID.randomUUID().toString(), updateOrderLister); orderService.completeOrder(order.getId().toString(), order, UUID.randomUUID().toString(), completeOrderListener); } catch (RemoteException e) { e.printStackTrace(); } } } } } } }
Example 18
Source File: Move.java From Camera-Roll-Android-App with Apache License 2.0 | 4 votes |
@Override public void execute(Intent workIntent) { File_POJO[] files = getFiles(workIntent); File_POJO target = workIntent.getParcelableExtra(TARGET); movedFilePaths = new ArrayList<>(); if (target == null) { return; } int success_count = 0; onProgress(success_count, files.length); //check if file is on removable storage boolean movingOntoRemovableStorage = Util.isOnRemovableStorage(target.getPath()); /*if (movingOntoRemovableStorage) { //failed = true; Uri treeUri = getTreeUri(workIntent, target.getPath()); if (treeUri == null) { return; } } else {*/ for (int i = files.length - 1; i >= 0; i--) { boolean movingFromRemovableStorage = Util.isOnRemovableStorage(files[i].getPath()); boolean result; if (movingFromRemovableStorage || movingOntoRemovableStorage) { //failed = true; Uri treeUri; if (movingFromRemovableStorage) { treeUri = getTreeUri(workIntent, files[i].getPath()); } else { treeUri = getTreeUri(workIntent, target.getPath()); } if (treeUri == null) { return; } result = copyAndDeleteFiles(getApplicationContext(), treeUri, files[i].getPath(), target.getPath()); //break; } else { result = moveFile(files[i].getPath(), target.getPath()); } //boolean result = moveFile(files[i].getPath(), target.getPath()); if (result) { movedFilePaths.add(files[i].getPath()); } success_count += result ? 1 : 0; onProgress(success_count, files.length); } //} /*if (failed) { showRemovableStorageToast(); } else */ if (success_count == 0) { onProgress(success_count, files.length); } }
Example 19
Source File: PgpEngine.java From Conversations with GNU General Public License v3.0 | 4 votes |
public long fetchKeyId(Account account, String status, String signature) { if ((signature == null) || (api == null)) { return 0; } if (status == null) { status = ""; } final StringBuilder pgpSig = new StringBuilder(); pgpSig.append("-----BEGIN PGP SIGNED MESSAGE-----"); pgpSig.append('\n'); pgpSig.append('\n'); pgpSig.append(status); pgpSig.append('\n'); pgpSig.append("-----BEGIN PGP SIGNATURE-----"); pgpSig.append('\n'); pgpSig.append('\n'); pgpSig.append(signature.replace("\n", "").trim()); pgpSig.append('\n'); pgpSig.append("-----END PGP SIGNATURE-----"); Intent params = new Intent(); params.setAction(OpenPgpApi.ACTION_DECRYPT_VERIFY); params.putExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true); InputStream is = new ByteArrayInputStream(pgpSig.toString().getBytes()); ByteArrayOutputStream os = new ByteArrayOutputStream(); Intent result = api.executeApi(params, is, os); switch (result.getIntExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR)) { case OpenPgpApi.RESULT_CODE_SUCCESS: OpenPgpSignatureResult sigResult = result .getParcelableExtra(OpenPgpApi.RESULT_SIGNATURE); if (sigResult != null) { return sigResult.getKeyId(); } else { return 0; } case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED: return 0; case OpenPgpApi.RESULT_CODE_ERROR: logError(account, result.getParcelableExtra(OpenPgpApi.RESULT_ERROR)); return 0; } return 0; }
Example 20
Source File: A2dpSinkHelper.java From sample-bluetooth-audio with Apache License 2.0 | 4 votes |
public static BluetoothDevice getDevice(Intent intent) { return intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); }