List of usage examples for android.content Intent setPackage
public @NonNull Intent setPackage(@Nullable String packageName)
From source file:net.olejon.mdapp.DonateActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Connected? if (!mTools.isDeviceConnected()) { mTools.showToast(getString(R.string.device_not_connected), 1); finish();/*from w w w . jav a 2 s . c om*/ return; } // Layout setContentView(R.layout.activity_donate); // Toolbar final Toolbar toolbar = (Toolbar) findViewById(R.id.donate_toolbar); toolbar.setTitle(getString(R.string.donate_title)); setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); // In-app billing Intent intent = new Intent("com.android.vending.billing.InAppBillingService.BIND"); intent.setPackage("com.android.vending"); bindService(intent, mServiceConnection, Context.BIND_AUTO_CREATE); // Buttons mMakeSmallDonationButton = (Button) findViewById(R.id.donate_make_small_donation); mMakeMediumDonationButton = (Button) findViewById(R.id.donate_make_medium_donation); mMakeBigDonationButton = (Button) findViewById(R.id.donate_make_big_donation); mMakeSmallDonationButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { makeDonation("small_donation"); } }); mMakeMediumDonationButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { makeDonation("medium_donation"); } }); mMakeBigDonationButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { makeDonation("big_donation"); } }); }
From source file:com.borqs.browser.search.OpenSearchSearchEngine.java
public void startSearch(Context context, String query, Bundle appData, String extraData) { Log.i("OpenSearchSearchEng", "startSearch, query: " + query); String uri = mSearchEngineInfo.getSearchUriForQuery(query); if (uri == null) { Log.e(TAG, "Unable to get search URI for " + mSearchEngineInfo); } else {//ww w .j a v a 2 s. c o m Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri)); // Make sure the intent goes to the Browser itself intent.setPackage(context.getPackageName()); intent.addCategory(Intent.CATEGORY_DEFAULT); intent.putExtra(SearchManager.QUERY, query); if (appData != null) { intent.putExtra(SearchManager.APP_DATA, appData); } if (extraData != null) { intent.putExtra(SearchManager.EXTRA_DATA_KEY, extraData); } intent.putExtra(Browser.EXTRA_APPLICATION_ID, context.getPackageName()); context.startActivity(intent); } }
From source file:com.android.stockbrowser.search.OpenSearchSearchEngine.java
public void startSearch(Context context, String query, Bundle appData, String extraData) { String uri = mSearchEngineInfo.getSearchUriForQuery(query); if (uri == null) { Log.e(TAG, "Unable to get search URI for " + mSearchEngineInfo); } else {/* ww w . ja v a 2s. c o m*/ Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri)); // Make sure the intent goes to the StockBrowser itself intent.setPackage(context.getPackageName()); intent.addCategory(Intent.CATEGORY_DEFAULT); intent.putExtra(SearchManager.QUERY, query); if (appData != null) { intent.putExtra(SearchManager.APP_DATA, appData); } if (extraData != null) { intent.putExtra(SearchManager.EXTRA_DATA_KEY, extraData); } intent.putExtra(Browser.EXTRA_APPLICATION_ID, context.getPackageName()); context.startActivity(intent); } }
From source file:com.dustinmreed.openwifi.DetailFragment.java
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor data) { if (data != null && data.moveToFirst()) { siteName = data.getString(COL_WIFILOCATION_NAME); mSiteNameView.setText(siteName); siteType = data.getString(COL_WIFILOCATION_TYPE); siteAddress = data.getString(COL_WIFILOCATION_ADDRESS); siteCity = data.getString(COL_WIFILOCATION_CITY); siteState = data.getString(COL_WIFILOCATION_STATE); siteZipcode = data.getString(COL_WIFILOCATION_ZIPCODE); mSiteAddressView.setText(getFormattedAddress(siteAddress, siteCity, siteState, siteZipcode)); latitude = Double.valueOf(data.getString(COL_WIFILOCATION_LAT)); longitude = Double.valueOf(data.getString(COL_WIFILOCATION_LONG)); favNavigation.setOnClickListener(new View.OnClickListener() { @Override//from ww w . j a v a 2 s . c o m public void onClick(View v) { Uri gmmIntentUri = Uri.parse("geo:" + latitude + ", " + longitude).buildUpon() .appendQueryParameter("q", siteAddress + ", " + siteCity).build(); // Uri gmmIntentUri = Uri.parse("google.navigation:q=Taronga+Zoo,+Sydney+Australia"); Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri); mapIntent.setPackage("com.google.android.apps.maps"); startActivity(mapIntent); } }); // Gets to GoogleMap from the MapView and does initialization stuff map = mapView.getMap(); map.getUiSettings().setMyLocationButtonEnabled(false); LatLng latlng = new LatLng(latitude, longitude); switch (siteType) { case "Library": map.addMarker(new MarkerOptions().position(latlng).title(siteName) .snippet(getFormattedAddress(siteAddress, siteCity, siteState, siteZipcode)) .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE))); break; case "Regional Community Center": map.addMarker(new MarkerOptions().position(latlng).title(siteName) .snippet(getFormattedAddress(siteAddress, siteCity, siteState, siteZipcode)) .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_ORANGE))); break; default: map.addMarker(new MarkerOptions().position(latlng).title(siteName) .snippet(getFormattedAddress(siteAddress, siteCity, siteState, siteZipcode)) .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_YELLOW))); break; } // Updates the location and zoom of the MapView //CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(new LatLng(36.05590917600006, -86.67243400799998), 20); // Move the camera instantly to location with a zoom of 15. map.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(latitude, longitude), 15)); // Zoom in, animating the camera. map.animateCamera(CameraUpdateFactory.zoomTo(14)); //map.animateCamera(cameraUpdate); // We still need this for the share intent mWiFiLocation = String.format("%s", siteName); // If onCreateOptionsMenu has already happened, we need to update the share intent now. if (mShareActionProvider != null) { mShareActionProvider.setShareIntent(createShareForecastIntent()); } } }
From source file:com.android.browser.search.OpenSearchSearchEngine.java
public void startSearch(Context context, String query, Bundle appData, String extraData) { String uri = mSearchEngineInfo.getSearchUriForQuery(query); if (uri == null) { Log.e(TAG, "Unable to get search URI for " + mSearchEngineInfo); } else {/* w w w . ja v a 2 s.co m*/ Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri)); // Make sure the intent goes to the Browser itself intent.setPackage(context.getPackageName()); intent.addCategory(Intent.CATEGORY_DEFAULT); intent.putExtra(SearchManager.QUERY, query); if (appData != null) { intent.putExtra(SearchManager.APP_DATA, appData); } if (extraData != null) { intent.putExtra(SearchManager.EXTRA_DATA_KEY, extraData); } intent.putExtra(Browser.EXTRA_APPLICATION_ID, context.getPackageName()); context.startActivity(intent); } }
From source file:com.thunder.iap.IAPActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //setContentView(R.layout.activity_main); Intent serviceIntent = new Intent("com.android.vending.billing.InAppBillingService.BIND"); serviceIntent.setPackage("com.android.vending"); bindService(serviceIntent, mServiceConn, Context.BIND_AUTO_CREATE); }
From source file:com.github.jvanhie.discogsscrobbler.SearchActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); if (id == R.id.search_barcode) { //start external barcode scanner intent try {/* ww w. j a v a2 s .co m*/ Intent intent = new Intent("com.google.zxing.client.android.SCAN"); intent.setPackage("com.google.zxing.client.android"); intent.putExtra("SCAN_MODE", "PRODUCT_MODE"); startActivityForResult(intent, BARCODE_REQUEST_CODE); } catch (ActivityNotFoundException exc) { //TODO: give users the option to download it } } if (id == R.id.detail_scrobble_release) { //if tracklist is available, always scrobble from this view if (mPanes == 3 && mReleaseTracklist != null) { mReleaseTracklist.scrobble(); } else if (mPanes == 2 && mReleasePager != null) { mReleasePager.scrobble(); } } if (id == R.id.detail_add_to_discogs) { //if tracklist is available, always scrobble from this view if (mPanes == 3 && mReleaseTracklist != null) { mReleaseTracklist.addToDiscogs(); } else if (mPanes == 2 && mReleasePager != null) { mReleasePager.addToDiscogs(); } } return super.onOptionsItemSelected(item); }
From source file:io.teak.sdk.GooglePlay.java
public void init(Context context) { mContext = context;//w ww . j a v a 2 s . c o m mServiceConn = new ServiceConnection() { @Override public void onServiceDisconnected(ComponentName name) { if (Teak.isDebug) { Log.d(LOG_TAG, "Google Play Billing service disconnected."); } mService = null; } @Override public void onServiceConnected(ComponentName name, IBinder service) { if (mDisposed) return; if (Teak.isDebug) { Log.d(LOG_TAG, "Google Play Billing service connected."); } try { Class<?> cls = Class.forName("com.android.vending.billing.IInAppBillingService$Stub"); Method m = cls.getMethod("asInterface", IBinder.class); mService = m.invoke(null, (Object) service); } catch (Exception e) { Log.e(LOG_TAG, "Unable to use 'IInAppBillingService' via reflection. " + Log.getStackTraceString(e)); Teak.sdkRaven.reportException(e); return; } String packageName = mContext.getPackageName(); try { if (Teak.isDebug) { Log.d(LOG_TAG, "Checking for Google Play in-app billing 3 support."); } // check for in-app billing v3 support Class<?> cls = Class.forName("com.android.vending.billing.IInAppBillingService"); Method m = cls.getMethod("isBillingSupported", int.class, String.class, String.class); int response = (Integer) m.invoke(mService, 3, packageName, ITEM_TYPE_INAPP); if (response != BILLING_RESPONSE_RESULT_OK) { Log.e(LOG_TAG, "Error checking for Google Play billing v3 support."); } else { if (Teak.isDebug) { Log.d(LOG_TAG, "Google Play In-app billing version 3 supported for " + packageName); } } // Check for v5 subscriptions support. This is needed for // getBuyIntentToReplaceSku which allows for subscription update response = (Integer) m.invoke(mService, 5, packageName, ITEM_TYPE_SUBS); if (response == BILLING_RESPONSE_RESULT_OK) { if (Teak.isDebug) { Log.d(LOG_TAG, "Google Play Subscription re-signup available."); Log.d(LOG_TAG, "Google Play Subscriptions available."); } } else { if (Teak.isDebug) { Log.d(LOG_TAG, "Google Play Subscription re-signup not available."); } // check for v3 subscriptions support response = (Integer) m.invoke(mService, 3, packageName, ITEM_TYPE_SUBS); if (response == BILLING_RESPONSE_RESULT_OK) { if (Teak.isDebug) { Log.d(LOG_TAG, "Google Play Subscriptions available."); } } else { if (Teak.isDebug) { Log.d(LOG_TAG, "Google Play Subscriptions NOT available. Response: " + response); } } } } catch (Exception e) { Log.e(LOG_TAG, "Error working with InAppBillingService: " + Log.getStackTraceString(e)); Teak.sdkRaven.reportException(e); } } }; Intent serviceIntent = new Intent("com.android.vending.billing.InAppBillingService.BIND"); serviceIntent.setPackage("com.android.vending"); List<ResolveInfo> intentServices = mContext.getPackageManager().queryIntentServices(serviceIntent, 0); if (intentServices != null && !intentServices.isEmpty()) { mContext.bindService(serviceIntent, mServiceConn, Context.BIND_AUTO_CREATE); } else { Log.e(LOG_TAG, "Google Play Billing service unavailable on device."); } }
From source file:com.google.fpl.gim.examplegame.MainActivity.java
@Override protected void onResume() { Utils.logDebug(TAG, "onResume"); super.onResume(); // Bind to the already running MainService so we can communicate with it. Intent intent = new Intent(this, MainService.class); intent.setPackage(getPackageName()); bindService(intent, mConnection, Context.BIND_WAIVE_PRIORITY); // Handles screen being asleep during run. Will display end screen if the run is over. checkDisplayEndScreen();/*from w w w .j a va 2s .co m*/ }
From source file:org.kontalk.ui.ContactsListFragment.java
private void startInvite() { Context ctx = getActivity();// ww w . j av a 2s. co m Intent shareIntent = SystemUtils.externalIntent(Intent.ACTION_SEND); shareIntent.setType(TextComponent.MIME_TYPE); shareIntent.putExtra(Intent.EXTRA_TEXT, getString(R.string.text_invite_message)); List<ResolveInfo> resInfo = ctx.getPackageManager().queryIntentActivities(shareIntent, 0); // having size=1 means that we are the only handlers if (resInfo != null && resInfo.size() > 1) { List<Intent> targets = new ArrayList<>(); for (ResolveInfo resolveInfo : resInfo) { String packageName = resolveInfo.activityInfo.packageName; if (!ctx.getPackageName().equals(packageName)) { // copy intent and add resolved info Intent targetShareIntent = new Intent(shareIntent); targetShareIntent.setPackage(packageName) .setComponent(new ComponentName(packageName, resolveInfo.activityInfo.name)) .putExtra("org.kontalk.invite.label", resolveInfo.activityInfo.loadLabel(ctx.getPackageManager())); targets.add(targetShareIntent); } } if (targets.size() > 0) { // initial intents are added before the main intent, so we remove the last one here Intent chooser = Intent.createChooser(targets.remove(targets.size() - 1), getString(R.string.menu_invite)); if (targets.size() > 0) { Collections.sort(targets, new DisplayNameComparator()); // remove custom extras for (Intent intent : targets) intent.removeExtra("org.kontalk.invite.label"); Parcelable[] extraIntents = targets.toArray(new Parcelable[targets.size()]); chooser.putExtra(Intent.EXTRA_INITIAL_INTENTS, extraIntents); } startActivity(chooser); return; } } // no activity to handle invitation Toast.makeText(ctx, R.string.warn_invite_no_app, Toast.LENGTH_SHORT).show(); }