List of usage examples for android.content Intent setPackage
public @NonNull Intent setPackage(@Nullable String packageName)
From source file:com.dwdesign.tweetings.activity.ImageViewerActivity.java
private void saveImage() { if (mImageFile != null && mImageFile.exists()) { final Uri uri = getIntent().getData(); if (uri == null) return; final String file_name = uri.getLastPathSegment(); final BitmapFactory.Options o = new BitmapFactory.Options(); o.inJustDecodeBounds = true;//from w ww. j a v a2 s . c o m BitmapFactory.decodeFile(mImageFile.getPath(), o); final String mime_type = o.outMimeType; String file_name_with_suffix = null; if (file_name.matches("(.*/)*.+\\.(png|jpg|gif|bmp|jpeg|PNG|JPG|JPEG|GIF|BMP)$")) { file_name_with_suffix = file_name; } else { if (mime_type == null) return; if (mime_type.startsWith("image/") && !"image/*".equals(mime_type)) { file_name_with_suffix = file_name + "." + mime_type.substring(5); } } final Intent intent = new Intent(INTENT_ACTION_SAVE_FILE); intent.setPackage(getPackageName()); intent.putExtra(INTENT_KEY_FILE_SOURCE, mImageFile.getPath()); intent.putExtra(INTENT_KEY_FILENAME, file_name_with_suffix); startActivity(intent); } }
From source file:me.trashout.fragment.CollectionPointDetailFragment.java
@OnClick(R.id.collection_point_detail_direction_btn) public void onDirectionClick() { if (mCollectionPoint != null && mCollectionPoint.getGps() != null) { Uri gmmIntentUri = Uri.parse("http://maps.google.com/maps?daddr=" + mCollectionPoint.getGps().getLat() + "," + mCollectionPoint.getGps().getLng()); Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri); mapIntent.setPackage("com.google.android.apps.maps"); if (mapIntent.resolveActivity(getActivity().getPackageManager()) != null) { startActivity(mapIntent);/*from w w w . j av a 2 s. c o m*/ } } }
From source file:org.linphone.purchase.InAppPurchaseHelper.java
public InAppPurchaseHelper(Activity context, InAppPurchaseListener listener) { mContext = context;/* w w w . ja v a 2 s . co m*/ mListener = listener; mGmailAccount = getGmailAccount(); Log.d("[In-app purchase] creating InAppPurchaseHelper for context " + context.getLocalClassName()); mServiceConn = new ServiceConnection() { @Override public void onServiceDisconnected(ComponentName name) { Log.d("[In-app purchase] onServiceDisconnected!"); mService = null; } @Override public void onServiceConnected(ComponentName name, IBinder service) { Log.d("[In-app purchase] onServiceConnected!"); mService = IInAppBillingService.Stub.asInterface(service); String packageName = mContext.getPackageName(); try { int response = mService.isBillingSupported(API_VERSION, packageName, ITEM_TYPE_SUBS); if (response != RESPONSE_RESULT_OK || mGmailAccount == null) { Log.e("[In-app purchase] Error: Subscriptions aren't supported!"); mListener.onError(CLIENT_ERROR_SUBSCRIPTION_PURCHASE_NOT_AVAILABLE); } else { mListener.onServiceAvailableForQueries(); } } catch (RemoteException e) { Log.e(e); } } }; Intent serviceIntent = new Intent("com.android.vending.billing.InAppBillingService.BIND"); serviceIntent.setPackage("com.android.vending"); if (!mContext.getPackageManager().queryIntentServices(serviceIntent, 0).isEmpty()) { boolean ok = mContext.bindService(serviceIntent, mServiceConn, Context.BIND_AUTO_CREATE); if (!ok) { Log.e("[In-app purchase] Error: Bind service failed"); mListener.onError(CLIENT_ERROR_BIND_TO_BILLING_SERVICE_FAILED); } } else { Log.e("[In-app purchase] Error: Billing service unavailable on device."); mListener.onError(CLIENT_ERROR_BILLING_SERVICE_UNAVAILABLE); } }
From source file:com.dwdesign.tweetings.app.TweetingsApplication.java
public void startMultiSelect() { mMultiSelectActive = true;/*w w w .j a va 2s. c om*/ final Intent intent = new Intent(BROADCAST_MULTI_SELECT_STATE_CHANGED); intent.setPackage(getPackageName()); sendBroadcast(intent); }
From source file:com.dwdesign.tweetings.app.TweetingsApplication.java
public void stopMultiSelect() { mSelectedItems.clear();/*from w ww. j a v a2 s. c o m*/ mMultiSelectActive = false; final Intent intent = new Intent(BROADCAST_MULTI_SELECT_STATE_CHANGED); intent.setPackage(getPackageName()); sendBroadcast(intent); }
From source file:me.henrytao.smoothappbarlayoutdemo.activity.BaseActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent serviceIntent = new Intent("com.android.vending.billing.InAppBillingService.BIND"); serviceIntent.setPackage("com.android.vending"); bindService(serviceIntent, mServiceConnection, Context.BIND_AUTO_CREATE); }
From source file:com.limemobile.app.plugin.PluginHostDelegateFragmentActivity.java
@Override public ComponentName startService(Intent service) { List<ResolveInfo> resolveInfos = getPackageManager().queryIntentServices(service, PackageManager.MATCH_DEFAULT_ONLY); if (resolveInfos == null || resolveInfos.isEmpty()) { service.setPackage(mDelegatedActivity.getPackageName()); } else {//from w ww. j ava 2 s .c o m return super.startService(service); } return PluginClientManager.sharedInstance(this).startService(this, service); }
From source file:com.limemobile.app.plugin.PluginHostDelegateFragmentActivity.java
@Override public boolean stopService(Intent service) { List<ResolveInfo> resolveInfos = getPackageManager().queryIntentServices(service, PackageManager.MATCH_DEFAULT_ONLY); if (resolveInfos == null || resolveInfos.isEmpty()) { service.setPackage(mDelegatedActivity.getPackageName()); } else {// w ww.j av a 2 s . c o m return super.stopService(service); } return PluginClientManager.sharedInstance(this).stopService(this, service); }
From source file:com.limemobile.app.plugin.PluginHostDelegateFragmentActivity.java
@Override public void startActivity(Intent intent) { List<ResolveInfo> resolveInfos = getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); if (resolveInfos == null || resolveInfos.isEmpty()) { intent.setPackage(mDelegatedActivity.getPackageName()); } else {/*from ww w . j a va2 s . c om*/ super.startActivity(intent); return; } PluginClientManager.sharedInstance(this).startActivity(this, intent); }
From source file:com.google.android.libraries.cast.companionlibrary.notification.VideoCastNotificationService.java
/** * Returns the {@link NotificationCompat.Action} for disconnecting this app from the cast * device.//from ww w. j ava 2 s. com */ protected NotificationCompat.Action getDisconnectAction() { Intent intent = new Intent(ACTION_STOP); intent.setPackage(getPackageName()); PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, intent, 0); return new NotificationCompat.Action.Builder(R.drawable.ic_notification_disconnect_24dp, getString(R.string.ccl_disconnect), pendingIntent).build(); }