當前位置: 首頁>>代碼示例>>Java>>正文


Java Intent.getParcelableExtra方法代碼示例

本文整理匯總了Java中android.content.Intent.getParcelableExtra方法的典型用法代碼示例。如果您正苦於以下問題:Java Intent.getParcelableExtra方法的具體用法?Java Intent.getParcelableExtra怎麽用?Java Intent.getParcelableExtra使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.content.Intent的用法示例。


在下文中一共展示了Intent.getParcelableExtra方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onReceive

import android.content.Intent; //導入方法依賴的package包/類
@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!");
    }
}
 
開發者ID:uhuru-mobile,項目名稱:mobile-store,代碼行數:30,代碼來源:SwapWorkflowActivity.java

示例2: setPowerNotificationRingtone

import android.content.Intent; //導入方法依賴的package包/類
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);
}
 
開發者ID:ric96,項目名稱:lineagex86,代碼行數:21,代碼來源:OtherSoundSettings.java

示例3: iniitialize

import android.content.Intent; //導入方法依賴的package包/類
@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);
    }
}
 
開發者ID:pedromassango,項目名稱:Programmers,代碼行數:20,代碼來源:Presenter.java

示例4: onCreate

import android.content.Intent; //導入方法依賴的package包/類
@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();
}
 
開發者ID:martinmarinov,項目名稱:AndroidDvbDriver,代碼行數:20,代碼來源:UsbDelegate.java

示例5: onNewIntent

import android.content.Intent; //導入方法依賴的package包/類
@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();
      }
    }
  }
}
 
開發者ID:SCHS-Robotics,項目名稱:Team9261-2017-2018,代碼行數:19,代碼來源:FtcRobotControllerActivity.java

示例6: handleSendImage

import android.content.Intent; //導入方法依賴的package包/類
@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;
}
 
開發者ID:sonnylazuardi,項目名稱:react-native-image-intent,代碼行數:16,代碼來源:ImageIntentModule.java

示例7: onNewIntent

import android.content.Intent; //導入方法依賴的package包/類
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();
    }
}
 
開發者ID:jopenbox,項目名稱:android-nfc,代碼行數:11,代碼來源:WriteUriActivity.java

示例8: onCreate

import android.content.Intent; //導入方法依賴的package包/類
@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);
    }
}
 
開發者ID:chuch0805,項目名稱:Android-Demo_ImageCroper,代碼行數:39,代碼來源:CropImageActivity.java

示例9: checkLocalStreams

import android.content.Intent; //導入方法依賴的package包/類
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;
}
 
開發者ID:PhoenixDevTeam,項目名稱:Phoenix-for-VK,代碼行數:32,代碼來源:ActivityUtils.java

示例10: onCreate

import android.content.Intent; //導入方法依賴的package包/類
@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);
}
 
開發者ID:Genymobile,項目名稱:gnirehtet,代碼行數:9,代碼來源:AuthorizationActivity.java

示例11: performReceive

import android.content.Intent; //導入方法依賴的package包/類
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);
    }
}
 
開發者ID:coding-dream,項目名稱:TPlayer,代碼行數:16,代碼來源:MethodProxies.java

示例12: onActivityResult

import android.content.Intent; //導入方法依賴的package包/類
@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);
}
 
開發者ID:gvsucis,項目名稱:mobile-app-dev-book,代碼行數:14,代碼來源:MainActivity.java

示例13: onReceive

import android.content.Intent; //導入方法依賴的package包/類
@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();
    }
}
 
開發者ID:kranthi0987,項目名稱:easyfilemanager,代碼行數:20,代碼來源:UsbStorageProvider.java

示例14: onReceive

import android.content.Intent; //導入方法依賴的package包/類
@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();
        }
    }
}
 
開發者ID:claudiodegio,項目名稱:dbsync,代碼行數:14,代碼來源:GDriveCloudProvider.java

示例15: onStart

import android.content.Intent; //導入方法依賴的package包/類
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;
}
 
開發者ID:amikey,項目名稱:DroidPlugin,代碼行數:16,代碼來源:ServcesManager.java


注:本文中的android.content.Intent.getParcelableExtra方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。