List of usage examples for android.content Intent setComponent
public @NonNull Intent setComponent(@Nullable ComponentName component)
From source file:com.crenativelabs.signchat.gcm.GcmBroadcastReceiver.java
@Override public void onReceive(Context context, Intent intent) { // Explicitly specify that GcmIntentService will handle the intent. // String className = GcmManager.getInstance(context) // .getHandleIntentServiceCompName(); ComponentName comp = new ComponentName(context.getPackageName(), MyGcmIntentService.class.getName()); // Start the service, keeping the device awake while it is launching. startWakefulService(context, (intent.setComponent(comp))); setResultCode(Activity.RESULT_OK);/*from w ww . ja v a 2 s . c o m*/ }
From source file:hk.edu.cityu.appslab.calmessenger.gcm.GcmBroadcastReceiver.java
@Override public void onReceive(Context context, Intent intent) { // Explicitly specify that GcmIntentService will handle the intent. System.out.println(MyGcmIntentService.class.getName()); String className = GcmManager.getInstance(context).getHandleIntentServiceCompName(); ComponentName comp = new ComponentName(context.getPackageName(), className); // Start the service, keeping the device awake while it is launching. startWakefulService(context, (intent.setComponent(comp))); setResultCode(Activity.RESULT_OK);/*from w w w .java 2s . co m*/ }
From source file:com.collecdoo.fragment.main.RegisterDriverPhotoFragment.java
private void openImageIntent(int uploadIndex) { //EasyImage.openChooserWithGallery(this,"Please choose",0); File imageFile = ImageHelper.createFile(context, "extend_picture.jpg"); String cameraImageFullPath = imageFile.getAbsolutePath(); cameraOutputFileUri = Uri.fromFile(imageFile); // Camera./*from w w w . j av a 2 s .c om*/ final List<Intent> cameraIntents = new ArrayList<Intent>(); final Intent captureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); final PackageManager packageManager = context.getPackageManager(); final List<ResolveInfo> listCam = packageManager.queryIntentActivities(captureIntent, 0); for (ResolveInfo res : listCam) { final String packageName = res.activityInfo.packageName; final Intent intent = new Intent(captureIntent); intent.setComponent(new ComponentName(res.activityInfo.packageName, res.activityInfo.name)); intent.setPackage(packageName); intent.putExtra(MediaStore.EXTRA_OUTPUT, cameraOutputFileUri); cameraIntents.add(intent); } // Filesystem. final Intent galleryIntent = new Intent(); galleryIntent.setType("image/*"); galleryIntent.setAction(Intent.ACTION_PICK); // Chooser of filesystem options. final Intent chooserIntent = Intent.createChooser(galleryIntent, "Select Source"); // Add the camera options. chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, cameraIntents.toArray(new Parcelable[] {})); startActivityForResult(chooserIntent, uploadIndex); }
From source file:org.catrobat.catroid.ui.dialogs.NewSpriteDialog.java
private void setupPaintroidButton(View parentView) { View paintroidButton = parentView.findViewById(R.id.dialog_new_object_paintroid); final Intent intent = new Intent("android.intent.action.MAIN"); intent.setComponent(new ComponentName(Constants.POCKET_PAINT_PACKAGE_NAME, Constants.POCKET_PAINT_INTENT_ACTIVITY_NAME)); paintroidButton.setOnClickListener(new View.OnClickListener() { @Override/* w w w. j a va 2 s . co m*/ public void onClick(View view) { if (LookController.getInstance().checkIfPocketPaintIsInstalled(intent, getActivity())) { Intent intent = new Intent("android.intent.action.MAIN"); intent.setComponent(new ComponentName(Constants.POCKET_PAINT_PACKAGE_NAME, Constants.POCKET_PAINT_INTENT_ACTIVITY_NAME)); Bundle bundleForPocketPaint = new Bundle(); bundleForPocketPaint.putString(Constants.EXTRA_PICTURE_PATH_POCKET_PAINT, ""); bundleForPocketPaint.putString(Constants.EXTRA_PICTURE_NAME_POCKET_PAINT, getString(R.string.default_look_name)); intent.putExtras(bundleForPocketPaint); intent.putExtra(MediaStore.EXTRA_OUTPUT, lookUri); intent.addCategory("android.intent.category.LAUNCHER"); startActivityForResult(intent, REQUEST_CREATE_POCKET_PAINT_IMAGE); } } }); }
From source file:org.onepf.oms.appstore.SamsungAppsBillingService.java
@Override public void startSetup(final OnIabSetupFinishedListener listener) { this.setupListener = listener; ComponentName com = new ComponentName(SamsungApps.IAP_PACKAGE_NAME, ACCOUNT_ACTIVITY_NAME); Intent intent = new Intent(); intent.setComponent(com); activity.startActivityForResult(intent, options.samsungCertificationRequestCode); }
From source file:com.uphyca.testing.junit3.support.v4.FragmentUnitTestCase.java
private void attachActivity(Object lastNonConfigurationInstance) throws Exception { if (mActivityAttached) { return;/* w w w. jav a 2s . c om*/ } IBinder token = null; if (mApplication == null) { setApplication(new MockApplication()); } if (mActivity == null) { setActivity(new MockFragmentActivity()); } ComponentName cn = new ComponentName(mActivity.getClass().getPackage().getName(), mActivity.getClass().getName()); Intent intent = new Intent(Intent.ACTION_MAIN); intent.setComponent(cn); ActivityInfo info = new ActivityInfo(); CharSequence title = mActivity.getClass().getName(); mMockParent = new MockParent(); String id = null; ActivityTrojanHorse.callAttach(getInstrumentation(), mActivity, mFragmentContext, token, mApplication, intent, info, title, mMockParent, id, lastNonConfigurationInstance); mActivityAttached = true; }
From source file:org.deviceconnect.android.manager.setting.DevicePluginInfoFragment.java
/** * Start a device plugin./* ww w. j a v a 2s.c o m*/ * * @param plugin device plugin to be started */ private void restartDevicePlugin(final DevicePlugin plugin) { Intent request = new Intent(); request.setComponent(plugin.getComponentName()); request.setAction(IntentDConnectMessage.ACTION_DEVICEPLUGIN_RESET); request.putExtra("pluginId", plugin.getPluginId()); try { plugin.send(request); } catch (MessagingException e) { showMessagingErrorDialog(e); } }
From source file:org.ohmage.prompt.remoteactivity.RemoteActivityPrompt.java
/** * Creates an Intent from the given 'activityName' and then launches the * Intent.//from www . j av a2s . c om */ private void launchActivity() { if (callingActivity != null) { Intent activityToLaunch = new Intent(actionName); activityToLaunch.setComponent(new ComponentName(packageName, activityName)); activityToLaunch.putExtra("input", input); try { callingActivity.startActivityForResult(activityToLaunch, 0); launched = true; runs++; } catch (ActivityNotFoundException e) { Toast.makeText(callingActivity, "Required component is not installed", Toast.LENGTH_SHORT).show(); } } else { Log.e(TAG, "The calling Activity was null."); } }
From source file:com.hellofyc.base.app.AppSupportDelegate.java
public void startFragmentForResult(@NonNull Intent intent, int requestCode, @Nullable Bundle options) { ComponentName componentName = intent.getComponent(); String targetFragmentClassName = componentName.getClassName(); intent.setComponent( new ComponentName(componentName.getPackageName(), SingleFragmentActivity.class.getName())); intent.putExtra(SingleFragmentActivity.EXTRA_FRAGMENT_CLASSNAME, targetFragmentClassName); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { mActivity.startActivityForResult(intent, requestCode, options); } else {//from ww w .j a v a 2 s .c o m mActivity.startActivityForResult(intent, requestCode); } }
From source file:com.emotiona.study.listviewpage.SwipeMenuListViewFragment.java
private void open(ApplicationInfo item) { // open app/*from w w w . j a v a 2 s .c o m*/ Intent resolveIntent = new Intent(Intent.ACTION_MAIN, null); resolveIntent.addCategory(Intent.CATEGORY_LAUNCHER); resolveIntent.setPackage(item.packageName); List<ResolveInfo> resolveInfoList = getActivity().getPackageManager().queryIntentActivities(resolveIntent, 0); if (resolveInfoList != null && resolveInfoList.size() > 0) { ResolveInfo resolveInfo = resolveInfoList.get(0); String activityPackageName = resolveInfo.activityInfo.packageName; String className = resolveInfo.activityInfo.name; Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_LAUNCHER); ComponentName componentName = new ComponentName(activityPackageName, className); intent.setComponent(componentName); startActivity(intent); } }