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:it.feio.android.omninotes.async.MainMenuTask.java
@Override protected void onPostExecute(final List<NavigationItem> items) { if (isAlive()) { mDrawerList.setAdapter(new NavDrawerAdapter(mainActivity, items)); mDrawerList.setOnItemClickListener((arg0, arg1, position, arg3) -> { String navigation = mFragmentWeakReference.get().getResources() .getStringArray(R.array.navigation_list_codes)[items.get(position).getArrayIndex()]; if (mainActivity.updateNavigation(navigation)) { mDrawerList.setItemChecked(position, true); if (mDrawerCategoriesList != null) mDrawerCategoriesList.setItemChecked(0, false); // Called to force redraw mainActivity.getIntent().setAction(Intent.ACTION_MAIN); EventBus.getDefault().post(new NavigationUpdatedEvent(mDrawerList.getItemAtPosition(position))); }/* w ww . j ava 2 s .co m*/ }); mDrawerList.justifyListViewHeightBasedOnChildren(); } }
From source file:cordova.BackgroundSubscribeIntentService.java
private void updateNotification() { List<String> messages = Utils.getCachedMessages(getApplicationContext()); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); Intent launchIntent = new Intent(getApplicationContext(), MainActivity.class); launchIntent.setAction(Intent.ACTION_MAIN); launchIntent.addCategory(Intent.CATEGORY_LAUNCHER); PendingIntent pi = PendingIntent.getActivity(getApplicationContext(), 0, launchIntent, PendingIntent.FLAG_UPDATE_CURRENT); String contentTitle = getContentTitle(messages); String contentText = getContentText(messages); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(android.R.drawable.star_on).setContentTitle(contentTitle).setContentText(contentText) .setStyle(new NotificationCompat.BigTextStyle().bigText(contentText)).setOngoing(true) .setContentIntent(pi);/*from w w w .j a va2s. co m*/ notificationManager.notify(MESSAGES_NOTIFICATION_ID, notificationBuilder.build()); }
From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.InviteToSharedAppFeedObj.java
public void handleDirectMessage(Context context, Contact from, JSONObject obj) { try {// w w w.j a va 2s . c o m String packageName = obj.getString(PACKAGE_NAME); String feedName = obj.getString("sharedFeedName"); JSONArray ids = obj.getJSONArray(PARTICIPANTS); Intent launch = new Intent(); launch.setAction(Intent.ACTION_MAIN); launch.addCategory(Intent.CATEGORY_LAUNCHER); launch.putExtra("type", "invite_app_feed"); launch.putExtra("creator", false); launch.putExtra("sender", from.id); launch.putExtra("sharedFeedName", feedName); launch.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); long[] idArray = new long[ids.length()]; for (int i = 0; i < ids.length(); i++) { idArray[i] = ids.getLong(i); } launch.putExtra("participants", idArray); launch.setPackage(packageName); final PackageManager mgr = context.getPackageManager(); List<ResolveInfo> resolved = mgr.queryIntentActivities(launch, 0); if (resolved.size() == 0) { Toast.makeText(context, "Could not find application to handle invite.", Toast.LENGTH_SHORT).show(); return; } ActivityInfo info = resolved.get(0).activityInfo; launch.setComponent(new ComponentName(info.packageName, info.name)); PendingIntent contentIntent = PendingIntent.getActivity(context, 0, launch, PendingIntent.FLAG_CANCEL_CURRENT); (new PresenceAwareNotify(context)).notify("New Invitation from " + from.name, "Invitation received from " + from.name, "Click to launch application: " + packageName, contentIntent); } catch (JSONException e) { Log.e(TAG, e.getMessage()); } }
From source file:it.gcaliendo.elytheme.fragments.FragmentExtras.java
private void actRequest() { String pkg = getResources().getString(R.string.pkg); Intent iconrequest = new Intent(Intent.ACTION_MAIN); iconrequest.setComponent(new ComponentName(pkg, pkg + ".RequestActivity")); try {//www.java 2s . c o m startActivity(iconrequest); } catch (RuntimeException icons) { icons.printStackTrace(); } }
From source file:org.mozilla.gecko.tests.BaseRobocopTest.java
public static Intent createActivityIntent(Map<String, String> config) { final Intent intent = new Intent(Intent.ACTION_MAIN); intent.putExtra("args", "-no-remote -profile " + config.get("profile")); // Don't show the first run experience. intent.putExtra(BrowserApp.EXTRA_SKIP_STARTPANE, true); final String envString = config.get("envvars"); if (!TextUtils.isEmpty(envString)) { final String[] envStrings = envString.split(","); for (int iter = 0; iter < envStrings.length; iter++) { intent.putExtra("env" + iter, envStrings[iter]); }// www .j a v a 2s. co m } return intent; }
From source file:com.dm.material.dashboard.candybar.tasks.IconRequestTask.java
@Override protected Boolean doInBackground(Void... voids) { while (!isCancelled()) { try {/*from w w w. j a v a 2s . c om*/ Thread.sleep(1); if (mContext.get().getResources().getBoolean(R.bool.enable_icon_request) || mContext.get().getResources().getBoolean(R.bool.enable_premium_request)) { List<Request> requests = new ArrayList<>(); HashMap<String, String> appFilter = RequestHelper.getAppFilter(mContext.get(), RequestHelper.Key.ACTIVITY); if (appFilter.size() == 0) { mError = Extras.Error.APPFILTER_NULL; return false; } PackageManager packageManager = mContext.get().getPackageManager(); Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_LAUNCHER); List<ResolveInfo> installedApps = packageManager.queryIntentActivities(intent, PackageManager.GET_RESOLVED_FILTER); if (installedApps == null || installedApps.size() == 0) { mError = Extras.Error.INSTALLED_APPS_NULL; return false; } CandyBarMainActivity.sInstalledAppsCount = installedApps.size(); try { Collections.sort(installedApps, new ResolveInfo.DisplayNameComparator(packageManager)); } catch (Exception ignored) { } for (ResolveInfo app : installedApps) { String packageName = app.activityInfo.packageName; String activity = packageName + "/" + app.activityInfo.name; String value = appFilter.get(activity); if (value == null) { String name = LocaleHelper.getOtherAppLocaleName(mContext.get(), new Locale("en"), packageName); if (name == null) { name = app.activityInfo.loadLabel(packageManager).toString(); } boolean requested = Database.get(mContext.get()).isRequested(activity); Request request = Request.Builder().name(name).packageName(app.activityInfo.packageName) .activity(activity).requested(requested).build(); requests.add(request); } } CandyBarMainActivity.sMissedApps = requests; } return true; } catch (Exception e) { CandyBarMainActivity.sMissedApps = null; mError = Extras.Error.DATABASE_ERROR; LogUtil.e(Log.getStackTraceString(e)); return false; } } return false; }
From source file:com.dycody.android.idealnote.async.MainMenuTask.java
@Override protected void onPostExecute(final List<NavigationItem> items) { if (isAlive()) { mDrawerList.setAdapter(new NavDrawerAdapter(mainActivity, items)); mDrawerList.setOnItemClickListener((arg0, arg1, position, arg3) -> { String navigation = mFragmentWeakReference.get().getResources() .getStringArray(com.dycody.android.idealnote.R.array.navigation_list_codes)[items .get(position).getArrayIndex()]; if (mainActivity.updateNavigation(navigation)) { mDrawerList.setItemChecked(position, true); if (mDrawerCategoriesList != null) mDrawerCategoriesList.setItemChecked(0, false); // Called to force redraw mainActivity.getIntent().setAction(Intent.ACTION_MAIN); EventBus.getDefault().post(new NavigationUpdatedEvent(mDrawerList.getItemAtPosition(position))); }/*from ww w. j a v a 2 s. com*/ }); mDrawerList.justifyListViewHeightBasedOnChildren(); } }
From source file:com.kectech.android.wyslink.service.MyGcmListenerService.java
/** * Create and show a simple notification containing the received GCM message. * * @param message GCM message received./*from w ww .ja va 2s .co m*/ */ private void sendNotification(String message) { // Intent intent = new Intent(this, MainActivity.class); // intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); // http://stackoverflow.com/questions/5502427/resume-application-and-stack-from-notification // use the same intent filters as android uses when launches the app final Intent intent = new Intent(this, MainActivity.class); intent.setAction(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_LAUNCHER); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_ONE_SHOT); Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); // http://stackoverflow.com/questions/25030710/gcm-push-notification-large-icon-size Bitmap largeIcon = BitmapFactory.decodeResource(getResources(), R.drawable.ic_notification_large); float multiplier = getImageFactor(getResources()); largeIcon = Bitmap.createScaledBitmap(largeIcon, (int) (largeIcon.getWidth() * multiplier), (int) (largeIcon.getHeight() * multiplier), false); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setLargeIcon(largeIcon).setSmallIcon(R.drawable.ic_stat_communication_message) .setContentTitle("wysLink Message").setContentText(message).setAutoCancel(true) .setSound(defaultSoundUri).setContentIntent(pendingIntent) .setVisibility(NotificationCompat.VISIBILITY_PRIVATE); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { // support from API 17 and above (Android 4.2) notificationBuilder.setSubText("click to open"); } NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); // Another issue i had in android lollipop is that the small icon was displayed next to the large icon. // http://stackoverflow.com/questions/16170648/android-notification-builder-show-a-notification-without-icon/33943309#33943309 Notification notification = notificationBuilder.build(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { int smallIconViewId = this.getResources().getIdentifier("right_icon", "id", android.R.class.getPackage().getName()); if (smallIconViewId != 0) { if (notification.contentIntent != null) notification.contentView.setViewVisibility(smallIconViewId, View.INVISIBLE); if (notification.headsUpContentView != null) notification.headsUpContentView.setViewVisibility(smallIconViewId, View.INVISIBLE); if (notification.bigContentView != null) notification.bigContentView.setViewVisibility(smallIconViewId, View.INVISIBLE); } } notificationManager.notify(0 /* ID of notification */, notification); }
From source file:org.catrobat.catroid.utils.StatusBarNotificationManager.java
public int createUploadNotification(Context context, String programName) { if (context == null || programName == null) { return -1; }/* w w w .ja v a2s. c om*/ initNotificationManager(context); Intent uploadIntent = new Intent(context, MainMenuActivity.class); uploadIntent.setAction(Intent.ACTION_MAIN); uploadIntent = uploadIntent.setFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); PendingIntent pendingIntent = PendingIntent.getActivity(context, notificationId, uploadIntent, PendingIntent.FLAG_CANCEL_CURRENT); NotificationData data = new NotificationData(context, pendingIntent, R.drawable.ic_stat, programName, R.string.notification_upload_title_pending, R.string.notification_upload_title_finished, R.string.notification_upload_pending, R.string.notification_upload_finished); int id = createNotification(context, data); showOrUpdateNotification(id, 0); return id; }
From source file:org.wahtod.wififixer.utility.NotifUtil.java
public static void addStatNotif(Context ctxt, StatusMessage in) { StatusMessage m = validateStrings(in); NotificationManager nm = (NotificationManager) ctxt.getSystemService(Context.NOTIFICATION_SERVICE); if (m.getShow() != 1) { cancel(ctxt, NotifUtil.STAT_TAG, NotifUtil.STATNOTIFID); mStatusBuilder = null;//from w w w . ja v a 2s. c om return; } if (mStatusBuilder == null) { Intent intent = new Intent(ctxt, MainActivity.class).setAction(Intent.ACTION_MAIN) .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); mStatusBuilder = new NotificationCompat.Builder(ctxt) .setContentIntent(PendingIntent.getActivity(ctxt, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT)) .setOngoing(true).setOnlyAlertOnce(true).setWhen(0) .setPriority(NotificationCompat.PRIORITY_DEFAULT) .setVisibility(NotificationCompat.VISIBILITY_PUBLIC) .addAction(R.drawable.reassociate, ctxt.getString(R.string.reassoc), PendingIntent.getBroadcast(ctxt, 0, new Intent(WidgetReceiver.REASSOCIATE), PendingIntent.FLAG_UPDATE_CURRENT)) .addAction(R.drawable.wifi, ctxt.getString(R.string.wifi), PendingIntent.getBroadcast(ctxt, 0, new Intent(IntentConstants.ACTION_WIFI_CHANGE), PendingIntent.FLAG_UPDATE_CURRENT)); } mStatusBuilder.setContentTitle(m.getSSID()); mStatusBuilder.setSmallIcon(R.drawable.notifsignal, m.getSignal()); mStatusBuilder.setLargeIcon(BitmapFactory.decodeResource(ctxt.getResources(), getIconfromSignal(m.getSignal(), ICON_SET_LARGE))); mStatusBuilder.setContentText(m.getStatus()); /* * Fire the notification */ nm.notify(NotifUtil.STAT_TAG, NotifUtil.STATNOTIFID, build(ctxt, mStatusBuilder, in)); }