List of usage examples for android.content Intent setPackage
public @NonNull Intent setPackage(@Nullable String packageName)
From source file:de.petendi.ethereum.android.EthereumAndroid.java
public int sendAsync(WrappedRequest request) { if (callback == null) { throw new IllegalStateException("no callback set"); }/*www . j a v a 2 s.c o m*/ try { Intent intent = new Intent(EthereumAndroidFactory.SERVICE_ACTION); intent.setPackage(EthereumAndroidFactory.PACKAGENAME); int id = messageId.incrementAndGet(); intent.putExtra(ID, id); intent.putExtra(EXTRA_DATA, objectMapper.writeValueAsString(request)); intent.putExtra(EXTRA_PACKAGE, packageName); context.startService(intent); return id; } catch (JsonProcessingException e) { throw new IllegalStateException(e); } }
From source file:com.pimp.instincts.activities.AboutActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: onBackPressed();/* ww w . j av a 2s . c om*/ break; case R.id.action_twitter: Intent browserIntent1 = new Intent(Intent.ACTION_VIEW, Uri.parse("https://twitter.com/ssn_instincts")); startActivity(browserIntent1); break; case R.id.action_facebook: Uri uri1 = Uri.parse("https://www.facebook.com/instincts.ssn"); try { this.getPackageManager().getPackageInfo("com.facebook.katana", 0); startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("fb://facewebmodal/f?href=" + uri1))); } catch (Exception e) { startActivity(new Intent(Intent.ACTION_VIEW, uri1)); } break; case R.id.action_instagram: Uri uri2 = Uri.parse("http://instagram.com/_u/ssninstincts"); try { Intent intent = new Intent(Intent.ACTION_VIEW, uri2); intent.setPackage("com.instagram.android"); startActivity(intent); } catch (ActivityNotFoundException e) { startActivity(new Intent(Intent.ACTION_VIEW, uri2)); } break; } return super.onOptionsItemSelected(item); }
From source file:de.petendi.ethereum.android.EthereumAndroid.java
public EthereumAndroid(Context context, EthereumAndroidCallback callback) { this.context = context; this.callback = callback; objectMapper = new ObjectMapper(); objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); EthereumAndroidService.responseHandler = new CallbackHandler(); packageName = context.getApplicationInfo().packageName; Intent intent = new Intent("de.petendi.ethereum.android.action.BIND_API"); intent.setPackage(EthereumAndroidFactory.PACKAGENAME); serviceConnection = new ServiceConnection() { @Override// www.j a v a2s . c o m public void onServiceConnected(ComponentName componentName, IBinder iBinder) { binder = IEthereumService.Stub.asInterface(iBinder); } @Override public void onServiceDisconnected(ComponentName componentName) { binder = null; } }; context.bindService(intent, serviceConnection, Context.BIND_AUTO_CREATE); }
From source file:com.google.android.apps.santatracker.cast.DataCastNotificationService.java
private void build(int titleId, int imageId) { // Main Content PendingIntent Intent contentIntent = new Intent(this, INTENT_ACTIVITY); // Disconnect PendingIntent Intent stopIntent = new Intent(ACTION_STOP); stopIntent.setPackage(getPackageName()); PendingIntent stopPendingIntent = PendingIntent.getBroadcast(this, 0, stopIntent, 0); // Media metadata String castingTo = getResources().getString(R.string.ccl_casting_to_device, mCastManager.getDeviceName()); TaskStackBuilder stackBuilder = TaskStackBuilder.create(this); stackBuilder.addParentStack(INTENT_ACTIVITY); stackBuilder.addNextIntent(contentIntent); PendingIntent contentPendingIntent = stackBuilder.getPendingIntent(NOTIFICATION_ID, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Builder builder = (NotificationCompat.Builder) new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.notification_small).setContentTitle(getResources().getString(titleId)) .setContentText(castingTo).setContentIntent(contentPendingIntent) .setColor(ContextCompat.getColor(this, R.color.brandSantaTracker)) .addAction(R.drawable.ic_notification_disconnect_24dp, getString(R.string.ccl_disconnect), stopPendingIntent)// w w w. j a v a 2s. c om .setOngoing(true).setShowWhen(false).setVisibility(NotificationCompat.VISIBILITY_PUBLIC); mNotification = builder.build(); }
From source file:com.ieeecsvit.riviera17android.activity.MainActivity.java
public Intent createEmailOnlyChooserIntent(Intent source, CharSequence chooserTitle) { Stack<Intent> intents = new Stack<Intent>(); Intent i = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", "tushar.narula17@live.com", null)); List<ResolveInfo> activities = getPackageManager().queryIntentActivities(i, 0); for (ResolveInfo ri : activities) { Intent target = new Intent(source); target.setPackage(ri.activityInfo.packageName); intents.add(target);// w w w. j a v a2 s . co m } if (!intents.isEmpty()) { Intent chooserIntent = Intent.createChooser(intents.remove(0), chooserTitle); chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, intents.toArray(new Parcelable[intents.size()])); return chooserIntent; } else { return Intent.createChooser(source, chooserTitle); } }
From source file:com.epsi.plugins.cordova.CafeBazaar.java
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) { if (action.equals("display-app")) { try {/* www . ja v a2s . com*/ JSONObject arg_object = args.getJSONObject(0); String app = arg_object.getString("app"); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse("bazaar://details?id=" + app)); intent.setPackage("com.farsitel.bazaar"); this.cordova.getActivity().startActivity(intent); callbackContext.success("success"); return true; } catch (Exception e) { System.err.println("Exception: " + e.getMessage()); callbackContext.error(e.getMessage()); return false; } } if (action.equals("rate-app")) { try { JSONObject arg_object = args.getJSONObject(0); String app = arg_object.getString("app"); Intent intent = new Intent(Intent.ACTION_EDIT); intent.setData(Uri.parse("bazaar://details?id=" + app)); intent.setPackage("com.farsitel.bazaar"); this.cordova.getActivity().startActivity(intent); callbackContext.success("success"); return true; } catch (Exception e) { System.err.println("Exception: " + e.getMessage()); callbackContext.error(e.getMessage()); return false; } } if (action.equals("disp-developer")) { try { JSONObject arg_object = args.getJSONObject(0); String developer = arg_object.getString("developer"); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse("bazaar://collection?slug=by_author&aid=" + developer)); intent.setPackage("com.farsitel.bazaar"); this.cordova.getActivity().startActivity(intent); callbackContext.success("success"); return true; } catch (Exception e) { System.err.println("Exception: " + e.getMessage()); callbackContext.error(e.getMessage()); return false; } } //callbackContext.error("false command"); return true; }
From source file:com.tangrainc.inappbilling.InAppBillingHelper.java
public InAppBillingHelper(Context context, String[] productIdentifiers) { _executor = MoreExecutors.listeningDecorator(Executors.newSingleThreadExecutor()); _productIdentifiers = productIdentifiers; _context = context;/* w ww .java 2 s . c o m*/ ServiceConnection _serviceConn = new ServiceConnection() { @Override public void onServiceDisconnected(ComponentName name) { Log.d(TAG, "Billing Service disconnected."); _service = null; } @Override public void onServiceConnected(ComponentName name, IBinder service) { Log.d(TAG, "Billing Service connected."); _service = IInAppBillingService.Stub.asInterface(service); } }; Intent serviceIntent = new Intent("com.android.vending.billing.InAppBillingService.BIND"); serviceIntent.setPackage("com.android.vending"); _context.bindService(serviceIntent, _serviceConn, Context.BIND_AUTO_CREATE); }
From source file:com.dynamixsoftware.printingsample.ShareIntentFragment.java
private boolean startActivityForResultFailed(Intent intent, String packageName, int requestCode) { try {/*from w w w.java2 s . co m*/ intent.setPackage(packageName); startActivityForResult(intent, requestCode); return false; } catch (ActivityNotFoundException e) { return true; } }
From source file:org.apache.cordova.plugin.Bazaar.java
@Override public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { if (action.equals("update")) { try {//from ww w. j ava 2 s .c om activity = this.cordova.getActivity(); callback = callbackContext; packageName = args.getString(0); connection = new UpdateServiceConnection(); Intent intent = new Intent("com.farsitel.bazaar.service.UpdateCheckService.BIND"); intent.setPackage("com.farsitel.bazaar"); boolean ret = activity.bindService(intent, connection, Context.BIND_AUTO_CREATE); if (ret == false) { callbackContext.error("Intent not bind"); return false; } return true; } catch (JSONException e) { callbackContext.error(e.getMessage()); return false; } } if (action.equals("show")) { try { packageName = args.getString(0); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse("bazaar://details?id=" + packageName)); intent.setPackage("com.farsitel.bazaar"); this.cordova.getActivity().startActivity(intent); callbackContext.success("View Intent Sent"); return true; } catch (JSONException e) { callbackContext.error(e.getMessage()); return false; } } if (action.equals("rate")) { try { packageName = args.getString(0); Intent intent = new Intent(Intent.ACTION_EDIT); intent.setData(Uri.parse("bazaar://details?id=" + packageName)); intent.setPackage("com.farsitel.bazaar"); this.cordova.getActivity().startActivity(intent); callbackContext.success("Rate Intent Sent"); return true; } catch (JSONException e) { callbackContext.error(e.getMessage()); return false; } } if (action.equals("developer")) { try { packageName = args.getString(0); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse("bazaar://collection?slug=by_author&aid=" + packageName)); intent.setPackage("com.farsitel.bazaar"); this.cordova.getActivity().startActivity(intent); callbackContext.success("Rate Intent Sent"); return true; } catch (JSONException e) { callbackContext.error(e.getMessage()); return false; } } return false; }
From source file:eu.faircode.adblocker.IAB.java
public void bind() { Log.i(TAG, "Bind"); Intent serviceIntent = new Intent("com.android.vending.billing.InAppBillingService.BIND"); serviceIntent.setPackage("com.android.vending"); context.bindService(serviceIntent, this, Context.BIND_AUTO_CREATE); }