List of usage examples for android.content Intent ACTION_MAIN
String ACTION_MAIN
To view the source code for android.content Intent ACTION_MAIN.
Click Source Link
From source file:Main.java
/** * Load the settings activity of a particular joyn client to enable or * disable the client//ww w . j a v a 2 s . c o m * * @param context Application context * @param appInfo Application info */ public static void loadJoynClientSettings(Context context, ResolveInfo appInfo) { Intent intent = new Intent(Intent.ACTION_MAIN); intent.setComponent(new ComponentName(appInfo.activityInfo.packageName, appInfo.activityInfo.name)); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); context.startActivity(intent); }
From source file:com.hkm.mmedic.utils.NotificationBuilder.java
public static Notification createServiceNotification(Context context, MediaMetadata metadata) { Intent notificationIntent = new Intent(context, MainActivity.class); notificationIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); notificationIntent.setAction(Intent.ACTION_MAIN); final PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0); final Notification notification = (new NotificationCompat.Builder(context)) .setSmallIcon(R.mipmap.ic_launcher).setContentIntent(contentIntent).setTicker(null) .setContentTitle(metadata.getTitile()).setContentText(metadata.getArtist()).setOngoing(true) .setWhen(0).build();/*from w ww .ja va2 s . c o m*/ return notification; }
From source file:Main.java
public static List<ResolveInfo> getAllAppInfo(Context context) { try {//from ww w . j a v a2 s.co m Intent mainIntent = new Intent(Intent.ACTION_MAIN, null); mainIntent.addCategory(Intent.CATEGORY_LAUNCHER); List<ResolveInfo> appList = context.getPackageManager().queryIntentActivities(mainIntent, 0); return appList; } catch (Exception e) { e.printStackTrace(); } return null; }
From source file:Main.java
/** * Create an {@link Intent} to launch an activity as the main entry point. Existing activities * will all be closed.// w w w. jav a 2 s . c o m */ public static Intent createRestartAppIntent(Uri data) { Intent i = new Intent(Intent.ACTION_MAIN, data); prepareRestartAppIntent(i); return i; }
From source file:Main.java
public static String getLauncherClassName(Context context) { PackageManager pm = context.getPackageManager(); Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_LAUNCHER); List<ResolveInfo> resolveInfos = pm.queryIntentActivities(intent, 0); for (ResolveInfo resolveInfo : resolveInfos) { String pkgName = resolveInfo.activityInfo.applicationInfo.packageName; if (pkgName.equalsIgnoreCase(context.getPackageName())) { String className = resolveInfo.activityInfo.name; return className; }/*from w w w . j a v a 2 s .c o m*/ } return null; }
From source file:com.fanfou.app.opensource.util.IntentHelper.java
public static Intent getLauncherIntent() { final Intent intent = new Intent(Intent.ACTION_MAIN); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.addCategory(Intent.CATEGORY_HOME); return intent; }
From source file:MainActivity.java
public void createShortcut(View view) { Intent shortcutIntent = new Intent(this, MainActivity.class); shortcutIntent.setAction(Intent.ACTION_MAIN); Intent installIntent = new Intent(); installIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); installIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.app_name)); installIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(this, R.mipmap.ic_launcher)); installIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT"); sendBroadcast(installIntent);/*from w ww. j a v a 2 s . c o m*/ }
From source file:com.h6ah4i.android.example.openslmediaplayer.app.utils.NotificationBuilder.java
public static Notification createServiceNotification(Context context, MediaMetadata metadata) { Intent notificationIntent = new Intent(context, MainActivity.class); notificationIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); notificationIntent.setAction(Intent.ACTION_MAIN); final PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0); final Notification notification = (new NotificationCompat.Builder(context)) .setSmallIcon(R.drawable.ic_launcher).setContentIntent(contentIntent).setTicker(null) .setContentTitle(metadata.getTitile()).setContentText(metadata.getArtist()).setOngoing(true) .setWhen(0).build();/* w ww . j a v a2 s . com*/ return notification; }
From source file:Main.java
/** * Retrieve launcher activity name of the application from the context * * @param context The context of the application package. * @return launcher activity name of this application. From the * "android:name" attribute.//from w w w . ja v a 2s . c o m */ private static String getLauncherClassName(Context context) { PackageManager packageManager = context.getPackageManager(); Intent intent = new Intent(Intent.ACTION_MAIN); // To limit the components this Intent will resolve to, by setting an // explicit package name. intent.setPackage(context.getPackageName()); intent.addCategory(Intent.CATEGORY_LAUNCHER); // All Application must have 1 Activity at least. // Launcher activity must be found! ResolveInfo info = packageManager.resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY); // get a ResolveInfo containing ACTION_MAIN, CATEGORY_LAUNCHER // if there is no Activity which has filtered by CATEGORY_DEFAULT if (info == null) { info = packageManager.resolveActivity(intent, 0); } return info.activityInfo.name; }
From source file:Main.java
public static String getMainProcessName(Context context) { Intent it = new Intent(Intent.ACTION_MAIN); it.setPackage(context.getPackageName()); ResolveInfo info = context.getPackageManager().resolveActivity(it, PackageManager.GET_RESOLVED_FILTER); String processName = null;/*from w w w. j av a 2 s .c om*/ if (info != null && info.activityInfo != null) { processName = info.activityInfo.processName; } else { processName = context.getPackageName(); } return processName; }