123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- package com.ysnows.sultra.utils;
- import android.content.ComponentName;
- import android.content.Context;
- import android.content.Intent;
- import com.ysnows.base.utils.ShellUtil;
- public class IntentUtils {
- public static Intent searchIntent(Context context, String kw) {
- Intent intent = new Intent("android.intent.action.WEB_SEARCH");
- intent.putExtra("query", kw);
- intent.setPackage(context.getPackageName());
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
- return intent;
- }
- public static Intent nIntent(String packageName, String className) {
- // if (ConfigColor.ClassName.WX_PAY_CODE.equals(className) || ConfigColor.ClassName.WX_FRIENDS_CIRCLE.equals(className)) {
- ShellUtil.checkRootPermission();
- // }
- Intent intent = new Intent();
- intent.setComponent(new ComponentName(packageName, className));
- return intent;
- }
- public static Intent nIntentWithAction(String action) {
- return new Intent(action);
- }
- public static Intent shareIntent(String packageName, String className, String content) {
- Intent intent = new Intent();
- intent.setComponent(new ComponentName(packageName, className));
- intent.setAction(Intent.ACTION_SEND);//设置分享行为
- intent.setType("text/plain");//设置分享内容的类型
- intent.putExtra(Intent.EXTRA_SUBJECT, "");//添加分享内容标题
- intent.putExtra(Intent.EXTRA_TEXT, content);//添加分享内容
- return intent;
- }
- public static Intent nIntentWithParams(String packageName, String className, String paramsName, String paramsValue) {
- // if (ConfigColor.ClassName.WX_PAY_CODE.equals(className) || ConfigColor.ClassName.WX_FRIENDS_CIRCLE.equals(className)) {
- ShellUtil.checkRootPermission();
- // }
- Intent intent = new Intent();
- intent.setComponent(new ComponentName(packageName, className));
- if ("@1".equals(paramsValue)) {
- intent.putExtra(paramsName, true);
- } else if ("@0".equals(paramsValue)) {
- intent.putExtra(paramsName, false);
- } else {
- intent.putExtra(paramsName, paramsValue);
- }
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
- return intent;
- }
- }
|