List of usage examples for android.content Intent addCategory
public @NonNull Intent addCategory(String category)
From source file:com.gigathinking.simpleapplock.UnlockWithGesture.java
@Override public void onBackPressed() { if (changeLock) { setResult(AppLockApplication.RESULT_NOT_OK); finish();/* ww w.j av a2 s.com*/ return; } Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_HOME); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); }
From source file:cn.edu.zafu.corepage.core.CoreConfig.java
/** * ???/*from ww w.j a v a2 s . c o m*/ */ public void exitApp() { Intent intent = new Intent(); intent.setAction(CoreConfig.ACTION_EXIT_APP); intent.addCategory(Intent.CATEGORY_DEFAULT); getLocalBroadcastManager().sendBroadcast(intent); BaseActivity.unInit(); }
From source file:com.powerall.plugin.barcodescanner.BarcodeScanner.java
/** * Starts an intent to scan and decode a barcode. *///from ww w . j a va2 s . com public void scan() { Intent intentScan = new Intent(SCAN_INTENT); intentScan.addCategory(Intent.CATEGORY_DEFAULT); this.cordova.startActivityForResult((CordovaPlugin) this, intentScan, REQUEST_CODE); }
From source file:com.phonegap.plugins.barcodescanner.BarcodeScanner.java
/** * Starts an intent to scan and decode a barcode. *//* w ww. j a v a 2 s . c om*/ public void scan() { Intent intentScan = new Intent("com.phonegap.plugins.barcodescanner.SCAN"); intentScan.addCategory(Intent.CATEGORY_DEFAULT); this.ctx.startActivityForResult((Plugin) this, intentScan, REQUEST_CODE); }
From source file:com.cloudstudio.BarcodeScanner.java
/** * Starts an intent to scan and decode a barcode. *///w ww. j a v a 2 s .c o m public void scan() { Intent intentScan = new Intent(SCAN_INTENT); intentScan.addCategory(Intent.CATEGORY_DEFAULT); // avoid calling other phonegap apps intentScan.setPackage(this.cordova.getActivity().getApplicationContext().getPackageName()); this.cordova.startActivityForResult((CordovaPlugin) this, intentScan, REQUEST_CODE); }
From source file:com.partypoker.poker.engagement.reach.EngagementPoll.java
@Override Intent buildIntent() {/*from ww w . j a va 2 s .c o m*/ Intent intent = new Intent(INTENT_ACTION); String category = getCategory(); if (category != null) intent.addCategory(category); return intent; }
From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.InviteToSharedAppFeedObj.java
public void handleDirectMessage(Context context, Contact from, JSONObject obj) { try {/*from ww w . j a v a 2 s. co 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:com.wso2.mobile.mdm.DisplayDeviceInfoActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK && FROM_ACTIVITY != null && FROM_ACTIVITY.equals(AlreadyRegisteredActivity.class.getSimpleName())) { Intent intent = new Intent(DisplayDeviceInfoActivity.this, AlreadyRegisteredActivity.class); intent.putExtra(getResources().getString(R.string.intent_extra_from_activity), DisplayDeviceInfoActivity.class.getSimpleName()); intent.putExtra(getResources().getString(R.string.intent_extra_regid), REG_ID); startActivity(intent);/*from w ww . j av a2s. c om*/ return true; } else if (keyCode == KeyEvent.KEYCODE_BACK) { Intent i = new Intent(); i.setAction(Intent.ACTION_MAIN); i.addCategory(Intent.CATEGORY_HOME); this.startActivity(i); this.finish(); return true; } return super.onKeyDown(keyCode, event); }
From source file:com.fitc.dooropener.lib.gcm.MyGcmListenerService.java
/** * Create and show a simple notification containing the received GCM message. * * @param status GCM message received.// www .ja va 2 s . c om */ private void sendNotification(GcmDataPayload status) { /** * This code should find launcher activity of app using this librbary and set it as the what gets launched */ Intent intent = null; final PackageManager packageManager = getPackageManager(); Log.i(TAG, "PACKAGE NAME " + getPackageName()); Intent mainIntent = new Intent(Intent.ACTION_MAIN, null); mainIntent.addCategory(Intent.CATEGORY_LAUNCHER); List<ResolveInfo> appList = packageManager.queryIntentActivities(mainIntent, 0); for (final ResolveInfo resolveInfo : appList) { if (getPackageName().equals(resolveInfo.activityInfo.packageName)) //if this activity is not in our activity (in other words, it's another default home screen) { intent = packageManager.getLaunchIntentForPackage(resolveInfo.activityInfo.packageName); break; } } PendingIntent pendingIntent = null; if (intent != null) { intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent, PendingIntent.FLAG_ONE_SHOT); } Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_stat_ic_notification) .setContentTitle(getResources().getString(R.string.notif_content_title)) .setContentText(status.getStatusData()).setAutoCancel(true).setSound(defaultSoundUri); if (pendingIntent != null) { notificationBuilder.setContentIntent(pendingIntent); } NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(0 /* ID of notification */, notificationBuilder.build()); }
From source file:com.esminis.server.library.service.server.ServerNotification.java
public void show(Context context, CharSequence title, CharSequence titlePublic) { if (!preferences.contains(context, Preferences.SHOW_NOTIFICATION_SERVER) || !preferences.getBoolean(context, Preferences.SHOW_NOTIFICATION_SERVER)) { hide(context);//ww w . j a v a 2 s. c o m return; } if (!serviceIsRunning) { serviceIsRunning = true; context.startService(new Intent(context, ServerNotificationService.class)); } if (notification == null) { Builder builder = setupNotificationBuilder(context, title) .setVisibility(NotificationCompat.VISIBILITY_PRIVATE) .setPublicVersion(setupNotificationBuilder(context, titlePublic).build()); Intent intent = new Intent(context, MainActivity.class); intent.setAction(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_LAUNCHER); builder.setContentIntent( PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT)); notification = builder.build(); } getManager(context).notify(NOTIFICATION_ID, notification); }