List of usage examples for android.content Intent addCategory
public @NonNull Intent addCategory(String category)
From source file:com.farmerbb.taskbar.fragment.FreeformModeFragment.java
@TargetApi(Build.VERSION_CODES.N) @Override// w w w . ja v a 2s.co m public boolean onPreferenceClick(final Preference p) { final SharedPreferences pref = U.getSharedPreferences(getActivity()); switch (p.getKey()) { case "freeform_hack": if (((CheckBoxPreference) p).isChecked()) { if (!U.hasFreeformSupport(getActivity())) { ((CheckBoxPreference) p).setChecked(false); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(R.string.freeform_dialog_title).setMessage(R.string.freeform_dialog_message) .setPositiveButton(R.string.action_developer_options, (dialogInterface, i) -> { showReminderToast = true; Intent intent = new Intent(Settings.ACTION_APPLICATION_DEVELOPMENT_SETTINGS); try { startActivity(intent); U.showToastLong(getActivity(), R.string.enable_force_activities_resizable); } catch (ActivityNotFoundException e) { intent = new Intent(Settings.ACTION_DEVICE_INFO_SETTINGS); try { startActivity(intent); U.showToastLong(getActivity(), R.string.enable_developer_options); } catch (ActivityNotFoundException e2) { /* Gracefully fail */ } } }); AlertDialog dialog = builder.create(); dialog.show(); dialog.setCancelable(false); } if (pref.getBoolean("taskbar_active", false) && getActivity().isInMultiWindowMode() && !FreeformHackHelper.getInstance().isFreeformHackActive()) { U.startFreeformHack(getActivity(), false, false); } } else { LocalBroadcastManager.getInstance(getActivity()) .sendBroadcast(new Intent("com.farmerbb.taskbar.FINISH_FREEFORM_ACTIVITY")); LocalBroadcastManager.getInstance(getActivity()) .sendBroadcast(new Intent("com.farmerbb.taskbar.FORCE_TASKBAR_RESTART")); } break; case "freeform_mode_help": AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setView(View.inflate(getActivity(), R.layout.freeform_help_dialog, null)) .setTitle(R.string.freeform_help_dialog_title).setPositiveButton(R.string.action_close, null); AlertDialog dialog = builder.create(); dialog.show(); break; case "add_shortcut": Intent intent = U.getShortcutIntent(getActivity()); intent.setAction("com.android.launcher.action.INSTALL_SHORTCUT"); intent.putExtra("duplicate", false); Intent homeIntent = new Intent(Intent.ACTION_MAIN); homeIntent.addCategory(Intent.CATEGORY_HOME); ResolveInfo defaultLauncher = getActivity().getPackageManager().resolveActivity(homeIntent, PackageManager.MATCH_DEFAULT_ONLY); intent.setPackage(defaultLauncher.activityInfo.packageName); getActivity().sendBroadcast(intent); U.showToast(getActivity(), R.string.shortcut_created); break; case "window_size": if (U.isOPreview()) { U.showToast(getActivity(), R.string.window_sizes_not_available); } break; } return true; }
From source file:com.github.jokar.rxupload.MainActivity.java
public void selectFile(View view) { Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("*/*");//???? intent.addCategory(Intent.CATEGORY_OPENABLE); startActivityForResult(intent, RESULT_SELECT_FILE); }
From source file:com.amgems.uwschedule.services.LoginService.java
protected void onHandleIntent(Intent intent) { LoginAuthenticator command = LoginAuthenticator.newInstance(getApplicationContext(), new Handler(), new DefaultHttpClient(), intent.getStringExtra(PARAM_IN_USERNAME), intent.getStringExtra(PARAM_IN_PASSWORD)); command.execute();/*from w w w . java2 s . co m*/ Response response = command.getResponse(); Intent broadcastIntent = new Intent(); LocalBroadcastManager broadcastManager = LocalBroadcastManager.getInstance(this); broadcastIntent.setAction(ACTION_RESPONSE); broadcastIntent.addCategory(Intent.CATEGORY_DEFAULT); broadcastIntent.putExtra(PARAM_OUT_RESPONSE, response); if (response == Response.OK) { broadcastIntent.putExtra(PARAM_OUT_COOKIE, command.getCookie().toString()); } broadcastManager.sendBroadcast(broadcastIntent); }
From source file:com.alibaba.weex.extend.module.WXEventModule.java
@JSMethod(uiThread = true) public void openURL(String url) { if (TextUtils.isEmpty(url)) { return;/*from w ww . jav a 2 s . co m*/ } String scheme = Uri.parse(url).getScheme(); StringBuilder builder = new StringBuilder(); if ("weex://go/scan".equals(url)) { if (ContextCompat.checkSelfPermission(mWXSDKInstance.getContext(), Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) { if (ActivityCompat.shouldShowRequestPermissionRationale((Activity) mWXSDKInstance.getContext(), Manifest.permission.CAMERA)) { Toast.makeText(mWXSDKInstance.getContext(), "Weex playground need the camera permission to scan QR code", Toast.LENGTH_SHORT) .show(); } else { ActivityCompat.requestPermissions((Activity) mWXSDKInstance.getContext(), new String[] { Manifest.permission.CAMERA }, CAMERA_PERMISSION_REQUEST_CODE); } } else { mWXSDKInstance.getContext() .startActivity(new Intent(mWXSDKInstance.getContext(), CaptureActivity.class)); } return; } if (TextUtils.equals("http", scheme) || TextUtils.equals("https", scheme) || TextUtils.equals("file", scheme)) { builder.append(url); } else { builder.append("http:"); builder.append(url); } Uri uri = Uri.parse(builder.toString()); Intent intent = new Intent(mWXSDKInstance.getContext(), WXPageActivity.class); intent.setAction(WEEX_ACTION); intent.setData(uri); intent.addCategory(WEEX_CATEGORY); mWXSDKInstance.getContext().startActivity(intent); if (mWXSDKInstance.checkModuleEventRegistered("event", this)) { HashMap<String, Object> params = new HashMap<>(); params.put("param1", "param1"); params.put("param2", "param2"); params.put("param3", "param3"); mWXSDKInstance.fireModuleEvent("event", this, params); } }
From source file:com.aylanetworks.aura.GcmIntentService.java
private void sendNotification(String msg, String sound) { mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE); // Find the launcher class for our application PackageManager pm = getPackageManager(); String packageName = getPackageName(); Intent query = new Intent(Intent.ACTION_MAIN); Class launcherClass = null;/*from w w w. j a v a 2s . co m*/ query.addCategory(Intent.CATEGORY_LAUNCHER); List<ResolveInfo> foundIntents = pm.queryIntentActivities(query, 0); for (ResolveInfo info : foundIntents) { if (TextUtils.equals(info.activityInfo.packageName, packageName)) { launcherClass = info.activityInfo.getClass(); } } if (launcherClass == null) { Log.e(TAG, "Could not find application launcher class"); return; } Intent appIntent = new Intent(this, launcherClass); // main activity of Ayla Control/aMCA PendingIntent contentIntent = PendingIntent.getActivity(this, 0, appIntent, 0); //Determine the sound to be played Uri soundUri = null; if (sound == null) { // NOP //PushNotification.playSound("bdth.mp3"); } else if (sound.equals("none")) { // NOP } else if (sound.equals("default")) { soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); // TYPE_NOTIFICATION or TYPE_ALARM } else if (sound.equals("alarm")) { soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM); // TYPE_NOTIFICATION or TYPE_ALARM } else { boolean playedSound; playedSound = PushNotification.playSound(sound); if (playedSound == false) { soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); // TYPE_NOTIFICATION or TYPE_ALARM } } // @formatter:off NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) //.setSound(soundUri) .setSmallIcon(R.drawable.ic_push_icon).setContentTitle(getResources().getString(R.string.app_name)) .setStyle(new NotificationCompat.BigTextStyle().bigText(msg)).setLights(0xFFff0000, 500, 500) // flashing red light .setContentText(msg).setAutoCancel(true) //.setPriority(Notification.FLAG_HIGH_PRIORITY) .setDefaults(Notification.DEFAULT_VIBRATE | Notification.FLAG_SHOW_LIGHTS); // @formatter:on if (soundUri != null) { mBuilder.setSound(soundUri); } mBuilder.setPriority(PRIORITY_MAX); mBuilder.setContentIntent(contentIntent); mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build()); }
From source file:com.google.android.demos.rss.app.ChannelActivity.java
private void addAlternativeOptionsMenuItems(Menu menu) { int groupId = MENU_GROUP_INTENT_OPTIONS; int itemId = Menu.NONE; int order = Menu.NONE; ComponentName caller = getComponentName(); Intent[] specifics = null;//from w ww. j a v a 2 s .c om Intent intent = new Intent(); intent.setData(getIntent().getData()); intent.addCategory(Intent.CATEGORY_ALTERNATIVE); int flags = 0; MenuItem[] outSpecificItems = null; menu.addIntentOptions(groupId, itemId, order, caller, specifics, intent, flags, outSpecificItems); }
From source file:com.dm.material.dashboard.candybar.adapters.IntentAdapter.java
private void sendRequest(ComponentName name) { try {//from w w w . j av a 2s .c om Intent intent = new Intent(Intent.ACTION_SEND); intent = addIntentExtra(intent); intent.setComponent(name); intent.addCategory(Intent.CATEGORY_LAUNCHER); mContext.startActivity(intent); } catch (IllegalArgumentException e) { try { Intent intent = new Intent(Intent.ACTION_SEND); intent = addIntentExtra(intent); mContext.startActivity( Intent.createChooser(intent, mContext.getResources().getString(R.string.email_client))); } catch (ActivityNotFoundException e1) { LogUtil.e(Log.getStackTraceString(e1)); } } }
From source file:cn.androidy.network.download.BroadcastNotifier.java
public void notifyProgress(int progress) { Intent localIntent = new Intent(); // The Intent contains the custom broadcast action for this app localIntent.setAction(Constants.BROADCAST_ACTION); localIntent.putExtra(Constants.EXTENDED_DATA_STATUS, progress); localIntent.addCategory(Intent.CATEGORY_DEFAULT); // Broadcasts the Intent mBroadcaster.sendBroadcast(localIntent); }
From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.AppReferenceObj.java
@Override public void handleDirectMessage(Context context, Contact from, JSONObject obj) { String packageName = obj.optString(PACKAGE_NAME); String arg = obj.optString(ARG); Intent launch = new Intent(); launch.setAction(Intent.ACTION_MAIN); launch.addCategory(Intent.CATEGORY_LAUNCHER); launch.putExtra(AppState.EXTRA_APPLICATION_ARGUMENT, arg); launch.putExtra("creator", false); launch.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); launch.setPackage(packageName);/*from w ww .j av a2 s .c o m*/ final PackageManager mgr = context.getPackageManager(); List<ResolveInfo> resolved = mgr.queryIntentActivities(launch, 0); if (resolved == null || 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", "Invitation received from " + from.name, "Click to launch application.", contentIntent); }
From source file:com.mobage.android.shellappsdk.sample.GameWebView.java
private boolean handleExternalDomainUrl(String url) { Uri uri = Uri.parse(url);//from ww w . j a v a2 s . co m String host = uri.getHost(); if (mDomainWhiteList.containsHost(host)) { return false; } // No match - Sending Intent to External Browser if ("http".equalsIgnoreCase(uri.getScheme()) || "https".equalsIgnoreCase(uri.getScheme())) { Intent intent = new Intent(Intent.ACTION_VIEW, uri); intent.addCategory(Intent.CATEGORY_BROWSABLE); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); if (getContext() instanceof Activity) { getContext().startActivity(intent); } } return true; }