List of usage examples for android.content Intent setPackage
public @NonNull Intent setPackage(@Nullable String packageName)
From source file:fr.shywim.antoinedaniel.ui.MainActivity.java
@Override public void onStart() { super.onStart(); if (!utils.signInFlowStarted) { mTaskFragment.connectPlayServices(findViewById(VIEW_ID_POPUPS)); }//w w w . j a va 2s . co m if (!IAPBound) { Intent intent = new Intent("com.android.vending.billing.InAppBillingService.BIND"); intent.setPackage("com.android.vending"); if (mAppContext != null) { IAPBound = mAppContext.bindService(intent, IAPConnection, Context.BIND_AUTO_CREATE); } } }
From source file:com.limemobile.app.plugin.PluginClientFragmentActivity.java
@Override public boolean stopService(Intent service) { if (mProxyActivity == null) { return super.stopService(service); }/* w ww. j a va2 s.co m*/ List<ResolveInfo> resolveInfos = mContext.getPackageManager().queryIntentServices(service, PackageManager.MATCH_DEFAULT_ONLY); if (resolveInfos != null && !resolveInfos.isEmpty()) { return super.stopService(service); } else { service.setPackage(mPluginPackage.mPackageName); return PluginClientManager.sharedInstance(mContext).stopService(mContext, service); } }
From source file:com.limemobile.app.plugin.PluginClientFragmentActivity.java
@Override public ComponentName startService(Intent service) { if (mProxyActivity == null) { return super.startService(service); }//from w w w . j a v a2s .c o m List<ResolveInfo> resolveInfos = mContext.getPackageManager().queryIntentServices(service, PackageManager.MATCH_DEFAULT_ONLY); if (resolveInfos != null && !resolveInfos.isEmpty()) { return super.startService(service); } else { service.setPackage(mPluginPackage.mPackageName); return PluginClientManager.sharedInstance(mContext).startService(mContext, service); } }
From source file:com.dwdesign.tweetings.fragment.UserListDetailsFragment.java
@Override public void onLinkClick(final String link, final int type) { if (mUserList == null) return;/*from w w w. ja v a 2 s.c om*/ switch (type) { case TwidereLinkify.LINK_TYPE_MENTION_LIST: { openUserProfile(getActivity(), mAccountId, -1, link); break; } case TwidereLinkify.LINK_TYPE_HASHTAG: { openTweetSearch(getActivity(), mAccountId, link); break; } case TwidereLinkify.LINK_TYPE_LINK_WITH_IMAGE_EXTENSION: { final Intent intent = new Intent(INTENT_ACTION_VIEW_IMAGE, Uri.parse(link)); intent.setPackage(getActivity().getPackageName()); startActivity(intent); break; } case TwidereLinkify.LINK_TYPE_LINK: { final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(link)); startActivity(intent); break; } case TwidereLinkify.LINK_TYPE_LIST: { final String[] mention_list = link.split("\\/"); if (mention_list == null || mention_list.length != 2) { break; } break; } } }
From source file:com.limemobile.app.plugin.PluginClientFragmentActivity.java
@Override public void startActivity(Intent intent) { if (mProxyActivity == null) { super.startActivity(intent); return;/*from w w w .ja va 2 s . c o m*/ } List<ResolveInfo> resolveInfos = mContext.getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); if (resolveInfos != null && !resolveInfos.isEmpty()) { super.startActivity(intent); } else { intent.setPackage(mPluginPackage.mPackageName); PluginClientManager.sharedInstance(mContext).startActivity(mContext, intent); } }
From source file:com.neighbor.ex.tong.ui.activity.MainActivity2Activity.java
private void startService() { String canonicalName = LppService.class.getCanonicalName(); boolean isService = AppUtil.checkServieRunning(getApplicationContext(), canonicalName); if (isService == false) { Intent intent = null; try {//from w w w . j a va 2 s .c o m intent = new Intent(getApplicationContext(), Class.forName(LppService.class.getName())); intent.setPackage("com.neighbor.ex.tong"); } catch (ClassNotFoundException e) { e.printStackTrace(); } if (intent != null) { // getApplicationContext().bindService(intent, serviceConnection, Context.BIND_AUTO_CREATE); startService(intent); } } }
From source file:org.anhonesteffort.flock.MigrationService.java
private void handleMigrationComplete() { Log.d(TAG, "handleMigrationComplete()"); if (intervalTimer != null) intervalTimer.cancel();//from w w w . ja v a2 s .c o m Intent intent = new Intent(); intent.setPackage(MigrationHelperBroadcastReceiver.class.getPackage().getName()); intent.setAction(ACTION_MIGRATION_COMPLETE); sendBroadcast(intent); stopForeground(false); stopSelf(); }
From source file:com.android.mail.browse.MessageAttachmentBar.java
@Override public void viewAttachment() { if (mAttachment.contentUri == null) { LogUtils.e(LOG_TAG, "viewAttachment with null content uri"); return;//from w w w.j av a2s .co m } Intent intent = new Intent(Intent.ACTION_VIEW); intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); final String contentType = mAttachment.getContentType(); Utils.setIntentDataAndTypeAndNormalize(intent, mAttachment.contentUri, contentType); // For EML files, we want to open our dedicated // viewer rather than let any activity open it. if (MimeType.isEmlMimeType(contentType)) { intent.setPackage(getContext().getPackageName()); intent.putExtra(AccountFeedbackActivity.EXTRA_ACCOUNT_URI, mAccount != null ? mAccount.uri : null); } try { getContext().startActivity(intent); } catch (ActivityNotFoundException e) { // couldn't find activity for View intent LogUtils.e(LOG_TAG, e, "Couldn't find Activity for intent"); } }
From source file:com.nutomic.syncthingandroid.util.BarcodeIntentIntegrator.java
/** * Shares the given text by encoding it as a barcode, such that another user can * scan the text off the screen of the device. * * @param text the text string to encode as a barcode * @param type type of data to encode. See {@code com.google.zxing.client.android.Contents.Type} constants. * @return the {@link AlertDialog} that was shown to the user prompting them to download the app * if a prompt was needed, or null otherwise *///from ww w .ja va 2 s . c o m @TargetApi(11) public final AlertDialog shareText(CharSequence text, CharSequence type) { Intent intent = new Intent(); intent.addCategory(Intent.CATEGORY_DEFAULT); intent.setAction(BS_PACKAGE + ".ENCODE"); intent.putExtra("ENCODE_TYPE", type); intent.putExtra("ENCODE_DATA", text); String targetAppPackage = findTargetAppPackage(intent); if (targetAppPackage == null) { return showDownloadDialog(); } intent.setPackage(targetAppPackage); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); attachMoreExtras(intent); if (fragment != null) { fragment.startActivity(intent); } else if (fragmentV4 != null) { fragmentV4.startActivity(intent); } else { activity.startActivity(intent); } return null; }
From source file:com.google.zxing.integration.android.SupportIntentIntegrator.java
/** * Shares the given text by encoding it as a barcode, such that another user can * scan the text off the screen of the device. * * @param text the text string to encode as a barcode * @param type type of data to encode. See {@code com.google.zxing.client.android.Contents.Type} constants. * @return the {@link AlertDialog} that was shown to the user prompting them to download the app * if a prompt was needed, or null otherwise *//*from w w w . j a v a2 s . c o m*/ public final AlertDialog shareText(CharSequence text, CharSequence type) { Intent intent = new Intent(); intent.addCategory(Intent.CATEGORY_DEFAULT); intent.setAction(BS_PACKAGE + ".ENCODE"); intent.putExtra("ENCODE_TYPE", type); intent.putExtra("ENCODE_DATA", text); String targetAppPackage = findTargetAppPackage(intent); if (targetAppPackage == null) { return showDownloadDialog(); } intent.setPackage(targetAppPackage); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); attachMoreExtras(intent); if (fragment != null) { fragment.startActivity(intent); } else if (fragmentV4 != null) { fragmentV4.startActivity(intent); } else { activity.startActivity(intent); } return null; }