List of usage examples for android.content Intent setClassName
public @NonNull Intent setClassName(@NonNull String packageName, @NonNull String className)
From source file:support.plus.reportit.MainActivity.java
private void shareAppLinkViaFacebook(String content) { try {/*w ww . ja v a2 s . co m*/ Intent intent1 = new Intent(); intent1.setClassName("com.facebook.katana", "com.facebook.katana.activity.composer.ImplicitShareIntentHandler"); intent1.setAction("android.intent.action.SEND"); intent1.setType("text/plain"); intent1.putExtra(Intent.EXTRA_TEXT, content); intent1.addCategory(Intent.CATEGORY_LAUNCHER); intent1.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); startActivity(intent1); } catch (Exception e) { // If we failed (no native FB app installed), try share through SEND Intent intent = new Intent(Intent.ACTION_SEND); String sharerUrl = "https://www.facebook.com/sharer/sharer.php?u=" + content; intent = new Intent(Intent.ACTION_VIEW, Uri.parse(sharerUrl)); startActivity(intent); } }
From source file:org.sipdroid.sipua.ui.Receiver.java
static Intent createHomeDockIntent() { Intent intent = new Intent(Intent.ACTION_MAIN, null); if (docked == EXTRA_DOCK_STATE_CAR) { intent.addCategory(CATEGORY_CAR_DOCK); } else if (docked == EXTRA_DOCK_STATE_DESK) { intent.addCategory(CATEGORY_DESK_DOCK); } else {// w w w. j a v a 2 s. co m return null; } ActivityInfo ai = intent.resolveActivityInfo(mContext.getPackageManager(), PackageManager.GET_META_DATA); if (ai == null) { return null; } if (ai.metaData != null && ai.metaData.getBoolean(METADATA_DOCK_HOME)) { intent.setClassName(ai.packageName, ai.name); return intent; } return null; }
From source file:com.miqtech.master.client.ui.StartActivity.java
@Override public void onClick(View v) { if (v.getId() == R.id.tvSkip) { Intent intent = new Intent(); if (isFirstStartOrUpdateVersion()) { PreferencesUtil.saveStartInfo(StartActivity.this); intent.setClass(StartActivity.this, GuideActivity.class); startActivity(intent);//www.j a v a 2 s .c o m } else { intent.setClass(context, MainActivity.class); if (mConfig != null && mConfig.getUpdate_msg() != null) { intent.putExtra("versionInfo", mConfig.getUpdate_msg()); } if (!isJumpFromWeb) { startActivity(intent); } else { Intent extraIntent = new Intent(); extraIntent.setClassName(StartActivity.this, data.getString("action")); String id = data.getString("id"); String key = data.getString("key"); extraIntent.putExtra(key, key.contains("activityId") ? Integer.parseInt(id) : id); startActivities(new Intent[] { intent, extraIntent }); } } timer.cancel(); onBackPressed(); } else if (v.getId() == R.id.ivAd) { String strConfig = PreferencesUtil.getConfig(this); mConfig = new Gson().fromJson(strConfig, Config.class); if (mConfig != null && mConfig.getStartup_ad() != null) { int type = mConfig.getStartup_ad().getType(); String target = mConfig.getStartup_ad().getTarget(); if (type == 1) { Intent mainIntent = new Intent(); mainIntent.setClass(this, MainActivity.class); Intent h5Intent = new Intent(); h5Intent.setClass(this, SubjectActivity.class); h5Intent.putExtra("url", target); h5Intent.putExtra(SubjectActivity.HTML5_TYPE, SubjectActivity.START_AD); Intent[] intents = new Intent[] { mainIntent, h5Intent }; startActivities(intents); timer.cancel(); } else if (type == 2) { if (target.equals("10")) { Intent mainIntent = new Intent(); mainIntent.setClass(this, MainActivity.class); Intent warIntent = new Intent(); warIntent.setClass(this, OfficalEventActivity.class); warIntent.putExtra("matchId", mConfig.getStartup_ad().getTarget_id()); Intent[] intents = new Intent[] { mainIntent, warIntent }; startActivities(intents); timer.cancel(); } else if (target.equals("11")) { Intent mainIntent = new Intent(); mainIntent.setClass(this, MainActivity.class); Intent recreationIntent = new Intent(); recreationIntent.setClass(this, RecreationMatchDetailsActivity.class); recreationIntent.putExtra("id", mConfig.getStartup_ad().getTarget_id()); Intent[] intents = new Intent[] { mainIntent, recreationIntent }; startActivities(intents); timer.cancel(); } else if (target.equals("12")) { Intent mainIntent = new Intent(); mainIntent.setClass(this, MainActivity.class); Intent yuezhnIntent = new Intent(); yuezhnIntent.setClass(this, YueZhanDetailsActivity.class); yuezhnIntent.putExtra("id", mConfig.getStartup_ad().getTarget_id()); Intent[] intents = new Intent[] { mainIntent, yuezhnIntent }; startActivities(intents); timer.cancel(); } } } } }
From source file:com.example.b1013029.myapplication.MapsActivity.java
private void test1() { String src_lat = "41.841817"; String src_ltg = "140.766969"; String des_lat = "41.830257"; String des_ltg = "140.761644"; Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity"); intent.setData(Uri.parse("http://maps.google.com/maps?saddr=" + src_lat + "," + src_ltg + "&daddr=" + des_lat + "," + des_ltg)); startActivity(intent);/*from w w w .j a v a 2s.c o m*/ }
From source file:com.arthackday.killerapp.GCMIntentService.java
@Override protected void onMessage(Context ctxt, Intent message) { Log.i("REMOVE BEFORE COMMIT", "blahhhhhhh GCMessage"); Bundle extras = message.getExtras(); /*/*from w ww . jav a 2 s . c o m*/ * TO DO! CHANGE WHAT THE MESSAGES DO!! */ for (String key : extras.keySet()) { Log.i(getClass().getSimpleName(), String.format("onMessage: %s=%s", key, extras.getString(key))); if (key.equals(KillerConstants.EXTRA_KEY_AUDIO)) { Log.i("REMOVE BEFORE COMMIT", "blahhhhhhh pushAudio"); Intent i = new Intent(); Log.i("REMOVE BEFORE COMMIT", extras.getString(key)); Bundle bundle = new Bundle(); //Add your data to bundle bundle.putString(KillerConstants.EXTRA_KEY_AUDIO, extras.getString(key)); //Add the bundle to the intent i.putExtras(bundle); i.setClassName("com.arthackday.killerapp", "com.arthackday.killerapp.PushAudio"); i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(i); } if (key.equals(KillerConstants.EXTRA_KEY_PUSHCALL)) { Log.i("REMOVE BEFORE COMMIT", "blahhhhhhh callnumber"); String number = extras.getString(KillerConstants.EXTRA_KEY_PUSHCALL); String uri = "tel:" + number.trim(); Intent intent = new Intent(Intent.ACTION_CALL); intent.setData(Uri.parse(uri)); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); } } }
From source file:com.example.b1013029.myapplication.MapsActivity.java
private void test0() { String start = "?"; String destination = ""; // :r//from w w w . ja va 2 s . c om //String dir = "r"; // :d //String dir = "d"; // ??:w String dir = "w"; Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity"); intent.setData(Uri .parse("http://maps.google.com/maps?saddr=" + start + "&daddr=" + destination + "&dirflg=" + dir)); startActivity(intent); }
From source file:cm.aptoide.pt.DownloadQueueService.java
private void setFinishedNotification(int apkidHash, String localPath) { String apkid = notifications.get(apkidHash).get("apkid"); int size = Integer.parseInt(notifications.get(apkidHash).get("intSize")); String version = notifications.get(apkidHash).get("version"); RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.download_notification); contentView.setImageViewResource(R.id.download_notification_icon, R.drawable.ic_notification); contentView.setTextViewText(R.id.download_notification_name, getString(R.string.finished_download_message) + " " + apkid + " v." + version); contentView.setProgressBar(R.id.download_notification_progress_bar, size * KBYTES_TO_BYTES, size * KBYTES_TO_BYTES, false); Intent onClick = new Intent("pt.caixamagica.aptoide.INSTALL_APK", Uri.parse("apk:" + apkid)); onClick.setClassName("cm.aptoide.pt", "cm.aptoide.pt.RemoteInTab"); onClick.setFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT | Intent.FLAG_ACTIVITY_NEW_TASK); onClick.putExtra("localPath", localPath); onClick.putExtra("apkid", apkid); onClick.putExtra("apkidHash", apkidHash); onClick.putExtra("isUpdate", Boolean.parseBoolean(notifications.get(apkid.hashCode()).get("isUpdate"))); /*Changed by Rafael Campos*/ onClick.putExtra("version", notifications.get(apkid.hashCode()).get("version")); Log.d("Aptoide-DownloadQueuService", "finished notification apkidHash: " + apkidHash + " localPath: " + localPath); // The PendingIntent to launch our activity if the user selects this notification PendingIntent onClickAction = PendingIntent.getActivity(context, 0, onClick, 0); Notification notification = new Notification(R.drawable.ic_notification, getString(R.string.finished_download_alrt) + " " + apkid, System.currentTimeMillis()); notification.flags |= Notification.FLAG_AUTO_CANCEL; notification.contentView = contentView; // Set the info for the notification panel. notification.contentIntent = onClickAction; // notification.setLatestEventInfo(this, getText(R.string.app_name), getText(R.string.add_repo_text), contentIntent); notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); // Send the notification. // We use the position because it is a unique number. We use it later to cancel. notificationManager.notify(apkidHash, notification); // Log.d("Aptoide-DownloadQueueService", "Notification Set"); }
From source file:org.mozilla.gecko.overlays.ui.ShareDialog.java
public void launchBrowser() { try {/*from w ww. ja v a 2 s.co m*/ // This can launch in the guest profile. Sorry. final Intent i = Intent.parseUri(url, Intent.URI_INTENT_SCHEME); i.setClassName(AppConstants.ANDROID_PACKAGE_NAME, AppConstants.MOZ_ANDROID_BROWSER_INTENT_CLASS); startActivity(i); } catch (URISyntaxException e) { // Nothing much we can do. } finally { slideOut(); } }
From source file:net.iamyellow.gcmjs.GcmjsModule.java
/** * Create big style notification/*w w w . ja v a 2 s .co m*/ * @param ntfId : counter for number of unread notification * @param title : notification title * @param message : notification body message * @param tickerText : notification text that appears on notification area when closed * @param icon : icon that will appear beside the notification * @param notificationId : unique notification id */ @Kroll.method public void createBigNotificationStyle(int ntfId, String title, String message, String tickerText, int icon, int notificationId) { Intent intent = new Intent(); intent.setAction("action" + ntfId); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP); intent.setClassName(TiApplication.getInstance().getApplicationContext().getPackageName(), TiApplication.getInstance().getPackageManager() .getLaunchIntentForPackage(TiApplication.getInstance().getPackageName()).getComponent() .getClassName()); intent.addCategory(Intent.CATEGORY_LAUNCHER); intent.putExtra("ntfId", ntfId); PendingIntent pintent = PendingIntent.getActivity(TiApplication.getInstance().getApplicationContext(), 0, intent, 0); NotificationCompat.Builder builder = new NotificationCompat.Builder( TiApplication.getInstance().getApplicationContext()).setContentIntent(pintent).setSmallIcon(icon) .setContentTitle(title).setContentText(message).setTicker(tickerText).setAutoCancel(true) .setNumber(ntfId) // .setDefaults(Notification.DEFAULT_ALL) // requires VIBRATE // permission /* * Sets the big view "big text" style and supplies the text (the * user's reminder message) that will be displayed in the detail * area of the expanded notification. These calls are ignored by * the support library for pre-4.1 devices. */ .setStyle(new NotificationCompat.BigTextStyle().bigText(message)); NotificationManager mNotificationManager = (NotificationManager) TiApplication.getInstance() .getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE); // notificationId allows you to update the notification later on. mNotificationManager.notify(notificationId, builder.build()); }
From source file:org.adblockplus.android.AdblockPlus.java
/** * Opens Android application settings/*from w w w . j av a 2s .com*/ */ public static void showAppDetails(Context context) { String packageName = context.getPackageName(); Intent intent = new Intent(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) { // above 2.3 intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); Uri uri = Uri.fromParts("package", packageName, null); intent.setData(uri); } else { // below 2.3 final String appPkgName = (Build.VERSION.SDK_INT == Build.VERSION_CODES.FROYO ? "pkg" : "com.android.settings.ApplicationPkgName"); intent.setAction(Intent.ACTION_VIEW); intent.setClassName("com.android.settings", "com.android.settings.InstalledAppDetails"); intent.putExtra(appPkgName, packageName); } intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); }