Java Code Examples for android.content.Intent.getParcelableExtra()

The following are Jave code examples for showing how to use getParcelableExtra() of the android.content.Intent class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: mobile-store   File: SwapWorkflowActivity.java   View Source Code Vote up 7 votes
@Override
public void onReceive(Context context, Intent intent) {
    switch (intent.getAction()) {
        case Installer.ACTION_INSTALL_STARTED:
            break;
        case Installer.ACTION_INSTALL_COMPLETE:
            localBroadcastManager.unregisterReceiver(this);

            showRelevantView(true);
            break;
        case Installer.ACTION_INSTALL_INTERRUPTED:
            localBroadcastManager.unregisterReceiver(this);
            // TODO: handle errors!
            break;
        case Installer.ACTION_INSTALL_USER_INTERACTION:
            PendingIntent installPendingIntent =
                    intent.getParcelableExtra(Installer.EXTRA_USER_INTERACTION_PI);

            try {
                installPendingIntent.send();
            } catch (PendingIntent.CanceledException e) {
                Log.e(TAG, "PI canceled", e);
            }

            break;
        default:
            throw new RuntimeException("intent action not handled!");
    }
}
 
Example 2
Project: lineagex86   File: OtherSoundSettings.java   View Source Code Vote up 7 votes
private void setPowerNotificationRingtone(Intent intent) {
    final Uri uri = intent.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);

    final String toneName;
    final String toneUriPath;

    if ( uri != null ) {
        final Ringtone ringtone = RingtoneManager.getRingtone(getActivity(), uri);
        toneName = ringtone.getTitle(getActivity());
        toneUriPath = uri.toString();
    } else {
        // silent
        toneName = getString(R.string.power_notifications_ringtone_silent);
        toneUriPath = POWER_NOTIFICATIONS_SILENT_URI;
    }

    mPowerSoundsRingtone.setSummary(toneName);
    CMSettings.Global.putString(getContentResolver(),
            CMSettings.Global.POWER_NOTIFICATIONS_RINGTONE, toneUriPath);
}
 
Example 3
Project: Programmers   File: Presenter.java   View Source Code Vote up 7 votes
@Override
public void iniitialize(Intent intent, Bundle bundle) {
    if (!_DEVELOP_MODE) {

        if (bundle != null) {
            usuario = bundle.getParcelable(EXTRA_USER);
        } else {

            FIRST_TIME = intent.getBooleanExtra(Constants._FIRST_TIME, false);
            usuario = intent.getParcelableExtra(EXTRA_USER);
        }

        if (FIRST_TIME) {
            view.disableEditEmail();
        }

        view.setupViews(usuario);
    }
}
 
Example 4
Project: AndroidDvbDriver   File: UsbDelegate.java   View Source Code Vote up 7 votes
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Intent intent = getIntent();
    if (UsbManager.ACTION_USB_DEVICE_ATTACHED.equals(intent.getAction())) {
        UsbDevice usbDevice = intent.getParcelableExtra(UsbManager.EXTRA_DEVICE);
        Log.d(TAG, "USB DVB-T attached: " + usbDevice.getDeviceName());
        Intent newIntent = new Intent(ACTION_DVB_DEVICE_ATTACHED);
        newIntent.putExtra(UsbManager.EXTRA_DEVICE, usbDevice);
        try {
            startActivity(newIntent);
        } catch (ActivityNotFoundException e) {
            Log.d(TAG, "No activity found for DVB-T handling");
        }
    }

    finish();
}
 
Example 5
Project: Team9261-2017-2018   File: FtcRobotControllerActivity.java   View Source Code Vote up 7 votes
@Override
protected void onNewIntent(Intent intent) {
  super.onNewIntent(intent);

  if (UsbManager.ACTION_USB_DEVICE_ATTACHED.equals(intent.getAction())) {
    UsbDevice usbDevice = intent.getParcelableExtra(UsbManager.EXTRA_DEVICE);
    RobotLog.vv(TAG, "ACTION_USB_DEVICE_ATTACHED: %s", usbDevice.getDeviceName());

    if (usbDevice != null) {  // paranoia
      // We might get attachment notifications before the event loop is set up, so
      // we hold on to them and pass them along only when we're good and ready.
      if (receivedUsbAttachmentNotifications != null) { // *total* paranoia
        receivedUsbAttachmentNotifications.add(usbDevice);
        passReceivedUsbAttachmentsToEventLoop();
      }
    }
  }
}
 
Example 6
Project: react-native-image-intent   File: ImageIntentModule.java   View Source Code Vote up 6 votes
@Nullable
private String handleSendImage(Intent intent) {
    Uri imageUri = (Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM);
    if (imageUri != null) {
        try {
            final InputStream imageStream = getCurrentActivity().getContentResolver().openInputStream(imageUri);
            final Bitmap selectedImage = BitmapFactory.decodeStream(imageStream);
            String encodedImage = encodeImage(selectedImage);

            return encodedImage;
        } catch(IOException e) {
        }
    }
    return null;
}
 
Example 7
Project: android-nfc   File: WriteUriActivity.java   View Source Code Vote up 6 votes
public void onNewIntent(Intent intent) {
    Tag detectedTag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
    NdefMessage ndefMessage = new NdefMessage(new NdefRecord[]{createUriRecord(mUri)});
    boolean result = writeTag(ndefMessage, detectedTag);
    if (result) {
        Toast.makeText(this, "写入成功", Toast.LENGTH_SHORT).show();
    } else {
        Toast.makeText(this, "写入失败", Toast.LENGTH_SHORT).show();
    }
}
 
Example 8
Project: Android-Demo_ImageCroper   File: CropImageActivity.java   View Source Code Vote up 6 votes
@Override
@SuppressLint("NewApi")
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.crop_image_activity);

    mCropImageView = (CropImageView) findViewById(R.id.cropImageView);

    Intent intent = getIntent();
    mCropImageUri = intent.getParcelableExtra(CropImage.CROP_IMAGE_EXTRA_SOURCE);
    mOptions = intent.getParcelableExtra(CropImage.CROP_IMAGE_EXTRA_OPTIONS);

    if (savedInstanceState == null) {
        if (mCropImageUri == null || mCropImageUri.equals(Uri.EMPTY)) {
            if (CropImage.isExplicitCameraPermissionRequired(this)) {
                // request permissions and handle the result in onRequestPermissionsResult()
                requestPermissions(new String[]{Manifest.permission.CAMERA}, CropImage.CAMERA_CAPTURE_PERMISSIONS_REQUEST_CODE);
            } else {
                CropImage.startPickImageActivity(this);
            }
        } else if (CropImage.isReadExternalStoragePermissionsRequired(this, mCropImageUri)) {
            // request permissions and handle the result in onRequestPermissionsResult()
            requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, CropImage.PICK_IMAGE_PERMISSIONS_REQUEST_CODE);
        } else {
            // no permissions required or already grunted, can start crop image activity
            mCropImageView.setImageUriAsync(mCropImageUri);
        }
    }

    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        String title = mOptions.activityTitle != null && !mOptions.activityTitle.isEmpty()
                ? mOptions.activityTitle
                : getResources().getString(R.string.crop_image_activity_title);
        actionBar.setTitle(title);
        actionBar.setDisplayHomeAsUpEnabled(true);
    }
}
 
Example 9
Project: Phoenix-for-VK   File: ActivityUtils.java   View Source Code Vote up 6 votes
public static ArrayList<Uri> checkLocalStreams(Activity activity) {
    Intent intent = activity.getIntent();
    if (intent == null) {
        return null;
    }

    Bundle extras = intent.getExtras();
    String action = intent.getAction();
    if (extras == null || action == null) {
        return null;
    }

    if (Intent.ACTION_SEND_MULTIPLE.equals(action)) {
        if (extras.containsKey(Intent.EXTRA_STREAM)) {
            return intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM);
        }
    }

    if (Intent.ACTION_SEND.equals(action)) {
        if (extras.containsKey(Intent.EXTRA_STREAM)) {
            Uri uri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
            if (uri != null) {
                ArrayList<Uri> streams = new ArrayList<>(1);
                streams.add(uri);
                return streams;
            }
        }
    }

    return null;
}
 
Example 10
Project: gnirehtet   File: AuthorizationActivity.java   View Source Code Vote up 6 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Intent intent = getIntent();
    Intent vpnIntent = intent.getParcelableExtra(EXTRA_VPN_INTENT);
    config = intent.getParcelableExtra(EXTRA_VPN_CONFIGURATION);
    startActivityForResult(vpnIntent, VPN_REQUEST_CODE);
}
 
Example 11
Project: TPlayer   File: MethodProxies.java   View Source Code Vote up 6 votes
public void performReceive(Intent intent, int resultCode, String data, Bundle extras, boolean ordered,
                           boolean sticky, int sendingUser) throws RemoteException {
    if (!accept(intent)) {
        return;
    }
    if (intent.hasExtra("_VA_|_intent_")) {
        intent = intent.getParcelableExtra("_VA_|_intent_");
    }
    SpecialComponentList.unprotectIntent(intent);
    if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN) {
        IIntentReceiverJB.performReceive.call(mOld, intent, resultCode, data, extras, ordered, sticky, sendingUser);
    } else {
        mirror.android.content.IIntentReceiver.performReceive.call(mOld, intent, resultCode, data, extras, ordered, sticky);
    }
}
 
Example 12
Project: mobile-app-dev-book   File: MainActivity.java   View Source Code Vote up 6 votes
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == NEW_TRIP_REQUEST) {
        if (data != null && data.hasExtra("TRIP")) {
            Parcelable par = data.getParcelableExtra("TRIP");
            Trip t = Parcels.unwrap(par);
            topRef.push().setValue(t);
            Snackbar.make(toolbar, "New Trip Added", Snackbar.LENGTH_SHORT).show();
        }
    }
    else
        super.onActivityResult(requestCode, resultCode, data);
}
 
Example 13
Project: easyfilemanager   File: UsbStorageProvider.java   View Source Code Vote up 6 votes
@Override
public void onReceive(Context context, Intent intent) {
    String action = intent.getAction();
    UsbDevice usbDevice = intent.getParcelableExtra(UsbManager.EXTRA_DEVICE);
    String deviceName = usbDevice.getDeviceName();
    if (UsbStorageProvider.ACTION_USB_PERMISSION.equals(action)) {
        boolean permission = intent.getBooleanExtra(UsbManager.EXTRA_PERMISSION_GRANTED, false);
        if (permission) {
            discoverDevice(usbDevice);
            notifyRootsChanged();
            notifyDocumentsChanged(getContext(), getRootId(usbDevice)+ROOT_SEPERATOR);
        } else {
            // so we don't ask for permission again
        }
    } else if (UsbManager.ACTION_USB_DEVICE_ATTACHED.equals(action)
            || UsbManager.ACTION_USB_DEVICE_DETACHED.equals(action)) {
        updateRoots();
    }
}
 
Example 14
Project: dbsync   File: GDriveCloudProvider.java   View Source Code Vote up 6 votes
@Override
public void onReceive(Context context, Intent intent) {
    final DriveId driveId = intent.getParcelableExtra(GDriveEventService.BUNDLE_DRIVEID);

    Log.i(TAG, "onReceive completion event for driveID:" + driveId.encodeToString());

    if (driveId.equals(mDriveId)) {
        result =  intent.getIntExtra(GDriveEventService.BUNDLE_SUCCESS, -1);
        synchronized (this) {
            notify();
        }
    }
}
 
Example 15
Project: DroidPlugin   File: ServcesManager.java   View Source Code Vote up 6 votes
public int onStart(Context context, Intent intent, int flags, int startId) throws Exception {
    Intent targetIntent = intent.getParcelableExtra(Env.EXTRA_TARGET_INTENT);
    if (targetIntent != null) {
        ServiceInfo targetInfo = PluginManager.getInstance().resolveServiceInfo(targetIntent, 0);
        if (targetInfo != null) {
            Service service = mNameService.get(targetInfo.name);
            if (service == null) {

                handleCreateServiceOne(context, intent, targetInfo);
            }
            handleOnStartOne(targetIntent, flags, startId);
        }
    }
    return -1;
}
 
Example 16
Project: YKCenterDemo-Android   File: YKWifiDeviceControlActivity.java   View Source Code Vote up 5 votes
private void initDevice() {
	Intent intent = getIntent();
	device = (GizWifiDevice) intent.getParcelableExtra("GizWifiDevice");
	rcCommand = intent.getStringExtra("rcCommand");
}
 
Example 17
Project: atlas   File: ActivityBridge.java   View Source Code Vote up 5 votes
private static Intent unWrapperOriginalIntent(Intent wrapper){
    return wrapper.getParcelableExtra("originalIntent");
}
 
Example 18
Project: container   File: StubActivityRecord.java   View Source Code Vote up 5 votes
public StubActivityRecord(Intent stub) {
    this.intent = stub.getParcelableExtra("_VA_|_intent_");
    this.info = stub.getParcelableExtra("_VA_|_info_");
    this.caller = stub.getParcelableExtra("_VA_|_caller_");
    this.userId = stub.getIntExtra("_VA_|_user_id_", 0);
}
 
Example 19
Project: Simpler   File: WBPostActivity.java   View Source Code Vote up 5 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_wb_post);
    ButterKnife.bind(this);

    if ("".equals(BaseConfig.sUid)) {
        // 没有授权用户
        AppToast.showToast("请先登录");
        App.getInstance().finishAllActivities();
        startActivity(WBLoginActivity.newIntent(this));
    }

    //声明LocationClient类
    mLocationClient = new LocationClient(getApplicationContext());
    //注册监听函数
    mLocationClient.registerLocationListener(myListener);
    mLocationClient.setLocOption(BDLocationUtil.getLocationClientOption());

    //设置布局管理器
    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
    linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
    mRvPhotos.setLayoutManager(linearLayoutManager);
    mPhotoAdapter = new PostPhotosAdapter(this, postPicClickListener);
    mRvPhotos.setAdapter(mPhotoAdapter);

    sContentBuilder = new StringBuilder();
    mEtContent.requestFocus();
    // 添加文本变化监听器
    mEtContent.addTextChangedListener(new StatusTextWatcher());

    Intent intent = getIntent();
    String action = intent.getAction();
    String type = intent.getType();
    if (Intent.ACTION_SEND.equals(action) && type != null) {
        mTvTitle.setText("分享给好友");
        if ("text/plain".equals(type)) {
            // 处理发来的文字
            String string = intent.getStringExtra(Intent.EXTRA_TEXT);
            mEtContent.setText(string);
            mEtContent.setSelection(mEtContent.length());
        } else if (type.startsWith("image/")) {
            // 处理发送来的图片
            handleSendImage(intent);
        } else if (type.startsWith("*/*")) {
            // 处理发送来的未知数据
            handleSendUnknown(intent);
        }
    } else if (Intent.ACTION_SEND_MULTIPLE.equals(action) && type != null) {
        if (type.startsWith("image/")) {
            // 处理发送来的多张图片
            handleSendMultipleImages(intent);
        } else if (type.startsWith("*/*")) {
            // 处理发送来的多个未知数据
            handleSendMultipleUnknown(intent);
        }
    } else {
        String title = intent.getStringExtra(INTENT_TITLE);
        mOldDraft = intent.getParcelableExtra(INTENT_DRAFT);
        if (mOldDraft != null) {
            init();     // 初始化发博器
        }
        if (!TextUtils.isEmpty(title)) {
            String text = intent.getStringExtra(INTENT_TEXT);
            String hint = intent.getStringExtra(INTENT_HINT);
            mTvTitle.setText(title);
            mEtContent.setHint(hint);
            mEtContent.setText(text);
            mEtContent.setSelection(mEtContent.length());
        }
    }
    // 打开输入法软键盘
    InputMethodUtils.openSoftKeyboard(this, mEtContent);
}
 
Example 20
Project: Minitask   File: NotificationPublisher.java   View Source Code Vote up 4 votes
public void onReceive(Context context, Intent intent) {

        NotificationManager notificationManager = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);

        Notification notification = intent.getParcelableExtra(NOTIFICATION);
        int id = intent.getIntExtra(NOTIFICATION_ID, 0);
        notificationManager.notify(id, notification);

    }