List of usage examples for android.content Intent setClassName
public @NonNull Intent setClassName(@NonNull String packageName, @NonNull String className)
From source file:org.thoughtcrime.securesms.logsubmit.SubmitLogFragment.java
private void handleShowChooserForIntent(final Intent intent, String chooserTitle) { final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); final ShareIntentListAdapter adapter = ShareIntentListAdapter.getAdapterForIntent(getActivity(), intent); builder.setTitle(chooserTitle).setAdapter(adapter, new DialogInterface.OnClickListener() { @Override/* w w w . ja va 2 s. c om*/ public void onClick(DialogInterface dialog, int which) { ActivityInfo info = adapter.getItem(which).activityInfo; intent.setClassName(info.packageName, info.name); startActivity(intent); emailActivityWasStarted = true; } }).setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialogInterface) { if (hackSavedLogUrl != null) handleShowSuccessDialog(hackSavedLogUrl); } }).create().show(); }
From source file:org.zeroxlab.zeroxbenchmark.Benchmark.java
public void onClick(View v) { if (v == mRun) { int numberOfCaseChecked = 0; for (int i = 0; i < mCheckList.length; i++) { if (mCheckList[i].isChecked()) { mCases.get(i).reset(); numberOfCaseChecked++; } else { mCases.get(i).clear(); }/*from ww w .j a va2 s. com*/ } if (numberOfCaseChecked > 0) runCase(mCases); } else if (v == mShow) { String result = getResult(); Log.i(TAG, "\n\n" + result + "\n\n"); writeResult(mOutputFile, result); Intent intent = new Intent(); intent.putExtra(Report.REPORT, result); intent.putExtra(Report.XML, mXMLResult); if (mAutoUpload) { intent.putExtra(Report.AUTOUPLOAD, true); mAutoUpload = false; } intent.setClassName(Report.packageName(), Report.fullClassName()); startActivity(intent); } else if (v == d2CheckBox || v == d3CheckBox || v == mathCheckBox || v == vmCheckBox || v == nativeCheckBox || v == miscCheckBox) { int length = mCases.size(); String tag = ((CheckBox) v).getText().toString(); for (int i = 0; i < length; i++) { if (!mCategory.get(tag).contains(mCases.get(i))) continue; mCheckList[i].setChecked(((CheckBox) v).isChecked()); } } }
From source file:cm.aptoide.com.facebook.android.Facebook.java
/** * Refresh OAuth access token method. Binds to Facebook for Android * stand-alone application application to refresh the access token. This * method tries to connect to the Facebook App which will handle the * authentication flow, and return a new OAuth access token. This method * will automatically replace the old token with a new one. Note that this * method is asynchronous and the callback will be invoked in the original * calling thread (not in a background thread). * //w ww . j ava 2 s. c o m * @param context * The Android Context that will be used to bind to the Facebook * RefreshToken Service * @param serviceListener * Callback interface for notifying the calling application when * the refresh request has completed or failed (can be null). In * case of a success a new token can be found inside the result * Bundle under Facebook.ACCESS_TOKEN key. * @return true if the binding to the RefreshToken Service was created */ public boolean extendAccessToken(Context context, ServiceListener serviceListener) { Intent intent = new Intent(); intent.setClassName("com.facebook.katana", "com.facebook.katana.platform.TokenRefreshService"); // Verify that the application whose package name is // com.facebook.katana // has the expected FB app signature. if (!validateServiceIntent(context, intent)) { return false; } return context.bindService(intent, new TokenRefreshServiceConnection(context, serviceListener), Context.BIND_AUTO_CREATE); }
From source file:cm.aptoide.com.facebook.android.Facebook.java
/** * Internal method to handle single sign-on backend for authorize(). * * @param activity/* w w w .jav a 2 s . co m*/ * The Android Activity that will parent the ProxyAuth Activity. * @param applicationId * The Facebook application identifier. * @param permissions * A list of permissions required for this application. If you do * not require any permissions, pass an empty String array. * @param activityCode * Activity code to uniquely identify the result Intent in the * callback. */ private boolean startSingleSignOn(Activity activity, String applicationId, String[] permissions, int activityCode) { boolean didSucceed = true; Intent intent = new Intent(); intent.setClassName("com.facebook.katana", "com.facebook.katana.ProxyAuth"); intent.putExtra("client_id", applicationId); if (permissions.length > 0) { intent.putExtra("scope", TextUtils.join(",", permissions)); } // Verify that the application whose package name is // com.facebook.katana.ProxyAuth // has the expected FB app signature. if (!validateActivityIntent(activity, intent)) { return false; } mAuthActivity = activity; mAuthPermissions = permissions; mAuthActivityCode = activityCode; try { activity.startActivityForResult(intent, activityCode); } catch (ActivityNotFoundException e) { didSucceed = false; } return didSucceed; }
From source file:og.android.tether.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem menuItem) { boolean supRetVal = super.onOptionsItemSelected(menuItem); Log.d(MSG_TAG, "Menuitem:getId - " + menuItem.getItemId()); switch (menuItem.getItemId()) { case MENU_SETUP: startActivityForResult(new Intent(MainActivity.this, SetupActivity.class), 0); break;//w w w .j a va 2s. c o m case MENU_LOG: startActivityForResult(new Intent(MainActivity.this, LogActivity.class), 0); break; case MENU_ABOUT: this.openAboutDialog(); break; case MENU_ACCESS: startActivityForResult(new Intent(MainActivity.this, AccessControlActivity.class), 0); break; case MENU_CONNECT: startActivity(new Intent(MainActivity.this, ConnectActivity.class)); break; case MENU_COMMUNITY: this.application.statCommunityClicks(); startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.communityUrl)))); break; case MENU_TWITTER: try { getPackageManager().getPackageInfo("com.twitter.android", PackageManager.GET_ACTIVITIES); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setClassName("com.twitter.android", "com.twitter.android.ProfileActivity"); intent.putExtra("user_id", 221897815L); startActivity(intent); } catch (PackageManager.NameNotFoundException e) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://twitter.com/OpenGarden"))); } break; case MENU_FACEBOOK: try { getPackageManager().getPackageInfo("com.facebook.katana", PackageManager.GET_ACTIVITIES); Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("fb://profile/199666333378900")); startActivity(intent); } catch (PackageManager.NameNotFoundException e) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://facebook.com/OpenGarden"))); } break; } return supRetVal; }
From source file:com.google.android.apps.chrometophone.C2DMReceiver.java
private Intent getLaunchIntent(Context context, String url, String title, String sel) { Intent intent = null; String number = parseTelephoneNumber(sel); if (number != null) { intent = new Intent("android.intent.action.DIAL", Uri.parse("tel:" + number)); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); ClipboardManager cm = (ClipboardManager) context.getSystemService(CLIPBOARD_SERVICE); cm.setText(number);//from www.j av a 2 s.co m } else if (sel != null && sel.length() > 0) { // No intent for selection - just copy to clipboard ClipboardManager cm = (ClipboardManager) context.getSystemService(CLIPBOARD_SERVICE); cm.setText(sel); } else { final String GMM_PACKAGE_NAME = "com.google.android.apps.maps"; final String GMM_CLASS_NAME = "com.google.android.maps.MapsActivity"; intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); if (isMapsURL(url)) { intent.setClassName(GMM_PACKAGE_NAME, GMM_CLASS_NAME); } // Fall back if we can't resolve intent (i.e. app missing) PackageManager pm = context.getPackageManager(); if (null == intent.resolveActivity(pm)) { intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); } } return intent; }
From source file:org.videolan.myvlc.core.mediaController.AudioService.java
private void updateWidgetPosition(Context context, float pos) { // no more than one widget update for each 1/50 of the song long timestamp = Calendar.getInstance().getTimeInMillis(); if (mCurrentMedia == null || timestamp - mWidgetPositionTimestamp < mCurrentMedia.getLength() / 50) return;//from ww w.j a v a2 s. c o m mWidgetPositionTimestamp = timestamp; Intent i = new Intent(); i.setClassName(WIDGET_PACKAGE, WIDGET_CLASS); i.setAction(ACTION_WIDGET_UPDATE_POSITION); i.putExtra("position", pos); sendBroadcast(i); }
From source file:org.videolan.myvlc.core.mediaController.AudioService.java
private void updateWidget(Context context) { Log.d(TAG, "Updating widget"); Intent i = new Intent(); i.setClassName(WIDGET_PACKAGE, WIDGET_CLASS); i.setAction(ACTION_WIDGET_UPDATE);//from w ww. j a v a2 s.com if (mCurrentMedia != null) { i.putExtra("title", mCurrentMedia.getTitle()); i.putExtra("artist", mCurrentMedia.getArtist()); } else { i.putExtra("title", context.getString(R.string.widget_name)); i.putExtra("artist", ""); } //i.putExtra("isplaying", mLibVLC.isPlaying()); //Bitmap cover = mCurrentMedia != null ? AudioUtil.getCover(this, mCurrentMedia, 64) : null; //i.putExtra("cover", cover); sendBroadcast(i); }
From source file:com.android.providers.downloads.DownloadInfo.java
public void sendIntentIfRequested() { if (mPackage == null) { return;/*from w ww . ja v a 2 s . c om*/ } Intent intent; if (mIsPublicApi) { intent = new Intent(DownloadManager.ACTION_DOWNLOAD_COMPLETE); intent.setPackage(mPackage); intent.putExtra(DownloadManager.EXTRA_DOWNLOAD_ID, mId); } else { // legacy behavior if (mClass == null) { return; } intent = new Intent(Downloads.Impl.ACTION_DOWNLOAD_COMPLETED); intent.setClassName(mPackage, mClass); if (mExtras != null) { intent.putExtra(Downloads.Impl.COLUMN_NOTIFICATION_EXTRAS, mExtras); } // We only send the content: URI, for security reasons. Otherwise, malicious // applications would have an easier time spoofing download results by // sending spoofed intents. intent.setData(getMyDownloadsUri()); } mSystemFacade.sendBroadcast(intent); }
From source file:uk.co.workingedge.phonegap.plugin.LaunchNavigator.java
private void launchGoogleMaps(JSONArray args, CallbackContext callbackContext) throws Exception { try {/*from w w w . j a v a 2 s . c om*/ String destination; String start = null; String dType = args.getString(1); if (dType.equals("pos")) { destination = getLocationFromPos(args, 2); } else { destination = getLocationFromName(args, 2); } String sType = args.getString(4); if (sType.equals("pos")) { start = getLocationFromPos(args, 5); } else if (sType.equals("name")) { start = getLocationFromName(args, 5); } String transportMode = args.getString(7); String launchMode = args.getString(8); String logMsg = "Using Google Maps to navigate to " + destination; String url; if (launchMode.equals("turn-by-turn")) { url = TURN_BY_TURN_PROTOCOL + "q=" + destination; if (!isNull(transportMode)) { logMsg += " by transportMode=" + transportMode; url += "&mode=" + transportMode; } logMsg += " in turn-by-turn mode"; } else { url = MAPS_PROTOCOL + "daddr=" + destination; if (!isNull(start)) { logMsg += " from " + start; url += "&saddr=" + start; } else { logMsg += " from current location"; } logMsg += " in maps mode"; } String extras = parseExtrasToUrl(args); if (!isNull(extras)) { url += extras; logMsg += " - extras=" + extras; } logDebug(logMsg); logDebug("URI: " + url); Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); intent.setClassName(supportedAppPackages.get(GOOGLE_MAPS), "com.google.android.maps.MapsActivity"); this.cordova.getActivity().startActivity(intent); callbackContext.success(); } catch (JSONException e) { String msg = e.getMessage(); if (msg.contains(NO_APP_FOUND)) { msg = "Google Maps app is not installed on this device"; } logError("Exception occurred: ".concat(msg)); callbackContext.error(msg); } }