当前位置: 首页>>代码示例>>Java>>正文


Java Intent.setClassName方法代码示例

本文整理汇总了Java中android.content.Intent.setClassName方法的典型用法代码示例。如果您正苦于以下问题:Java Intent.setClassName方法的具体用法?Java Intent.setClassName怎么用?Java Intent.setClassName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.content.Intent的用法示例。


在下文中一共展示了Intent.setClassName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: goToInstalledAppDetails

import android.content.Intent; //导入方法依赖的package包/类
/**
 * 打开已安装应用的详情
 */
public static void goToInstalledAppDetails(Context context, String packageName) {
    Intent intent = new Intent();
    int sdkVersion = Build.VERSION.SDK_INT;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
        intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
        intent.setData(Uri.fromParts("package", packageName, null));
    } else {
        intent.setAction(Intent.ACTION_VIEW);
        intent.setClassName("com.android.settings", "com.android.settings.InstalledAppDetails");
        intent.putExtra((sdkVersion == Build.VERSION_CODES.FROYO ? "pkg"
                : "com.android.settings.ApplicationPkgName"), packageName);
    }
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);
}
 
开发者ID:jqjm,项目名称:Liteframework,代码行数:19,代码来源:PackageUtil.java

示例2: onClick

import android.content.Intent; //导入方法依赖的package包/类
@Override
public void onClick(View v) {
	Intent intent = new Intent();
	switch (v.getId()) {
	case R.id.mintest:
    	intent.setClassName("net.fercanet.LNM", "net.fercanet.LNM.Game");
    	intent.putExtra("omt", true);
    	startActivity(intent);
	break;
	case R.id.training:	
    	intent.setClassName("net.fercanet.LNM", "net.fercanet.LNM.Game");
    	intent.putExtra("omt", false);
    	startActivity(intent);
	break;
	case R.id.hof:	
    	intent.setClassName("net.fercanet.LNM", "net.fercanet.LNM.Hof");
    	startActivity(intent);

   	break;
	case R.id.endgame:	
    	moveTaskToBack(true);

   	break;
	}
}
 
开发者ID:sdrausty,项目名称:buildAPKsApps,代码行数:26,代码来源:MainMenu.java

示例3: handleInstallShortcutIntent

import android.content.Intent; //导入方法依赖的package包/类
private Intent handleInstallShortcutIntent(Intent intent) {
    Intent shortcut = intent.getParcelableExtra(Intent.EXTRA_SHORTCUT_INTENT);
    if (shortcut != null) {
        ComponentName component = shortcut.resolveActivity(VirtualCore.getPM());
        if (component != null) {
            String pkg = component.getPackageName();
            Intent newShortcutIntent = new Intent();
            newShortcutIntent.setClassName(getHostPkg(), Constants.SHORTCUT_PROXY_ACTIVITY_NAME);
            newShortcutIntent.addCategory(Intent.CATEGORY_DEFAULT);
            newShortcutIntent.putExtra("_VA_|_intent_", shortcut);
            newShortcutIntent.putExtra("_VA_|_uri_", shortcut.toUri(0));
            newShortcutIntent.putExtra("_VA_|_user_id_", VUserHandle.myUserId());
            intent.removeExtra(Intent.EXTRA_SHORTCUT_INTENT);
            intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, newShortcutIntent);

            Intent.ShortcutIconResource icon = intent.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE);
            if (icon != null && !TextUtils.equals(icon.packageName, getHostPkg())) {
                try {
                    Resources resources = VirtualCore.get().getResources(pkg);
                    if (resources != null) {
                        int resId = resources.getIdentifier(icon.resourceName, "drawable", pkg);
                        if (resId > 0) {
                            Drawable iconDrawable = resources.getDrawable(resId);
                            Bitmap newIcon = BitmapUtils.drawableToBitmap(iconDrawable);
                            if (newIcon != null) {
                                intent.removeExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE);
                                intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, newIcon);
                            }
                        }
                    }
                } catch (Throwable e) {
                    e.printStackTrace();
                }
            }
        }
    }
    return intent;
}
 
开发者ID:codehz,项目名称:container,代码行数:39,代码来源:BroadcastIntent.java

示例4: showInstalledAppDetails

import android.content.Intent; //导入方法依赖的package包/类
public static void showInstalledAppDetails(Context context, String packageName) {
    Intent intent = new Intent();
    final int apiLevel = Build.VERSION.SDK_INT;
    if (apiLevel >= 9) { // above 2.3
        intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
        Uri uri = Uri.fromParts(SCHEME, packageName, null);
        intent.setData(uri);
    } else { // below 2.3
        final String appPkgName = (apiLevel == 8 ? APP_PKG_NAME_22
                : APP_PKG_NAME_21);
        intent.setAction(Intent.ACTION_VIEW);
        intent.setClassName(APP_DETAILS_PACKAGE_NAME,
                APP_DETAILS_CLASS_NAME);
        intent.putExtra(appPkgName, packageName);
    }
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:19,代码来源:ApplicationInfo.java

示例5: setup

import android.content.Intent; //导入方法依赖的package包/类
@Before
public void setup() throws InterruptedException {
    synchronized (objectLock) {
        Intent remoterServiceIntent = new Intent(INTENT_AIDL_SERVICE);
        remoterServiceIntent.setClassName("util.remoter.aidlservice", INTENT_AIDL_SERVICE);

        mActivityRule.getActivity().startService(remoterServiceIntent);
        mActivityRule.getActivity().bindService(remoterServiceIntent, serviceConnection, 0);

        objectLock.wait();
        Log.i(TAG, "Service connected");
    }
}
 
开发者ID:josesamuel,项目名称:remoter,代码行数:14,代码来源:RemoterClientToAidlServerTest.java

示例6: ApplicationInfo

import android.content.Intent; //导入方法依赖的package包/类
/**
 * 应用信息界面
 * @param activity
 */
public static void ApplicationInfo(Activity activity){
    Intent localIntent = new Intent();
    localIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    if (Build.VERSION.SDK_INT >= 9) {
        localIntent.setAction("android.settings.APPLICATION_DETAILS_SETTINGS");
        localIntent.setData(Uri.fromParts("package", activity.getPackageName(), null));
    } else if (Build.VERSION.SDK_INT <= 8) {
        localIntent.setAction(Intent.ACTION_VIEW);
        localIntent.setClassName("com.android.settings", "com.android.settings.InstalledAppDetails");
        localIntent.putExtra("com.android.settings.ApplicationPkgName", activity.getPackageName());
    }
    activity.startActivity(localIntent);
}
 
开发者ID:xmlxin,项目名称:ReplyMessage,代码行数:18,代码来源:JumpPermissionManagement.java

示例7: isActivityExists

import android.content.Intent; //导入方法依赖的package包/类
/**
 * 判断是否存在Activity
 *
 * @param packageName 包名
 * @param className   activity全路径类名
 * @return {@code true}: 是<br>{@code false}: 否
 */
public static boolean isActivityExists(@NonNull final String packageName,
                                       @NonNull final String className) {
    Intent intent = new Intent();
    intent.setClassName(packageName, className);
    return !(Utils.getContext().getPackageManager().resolveActivity(intent, 0) == null ||
            intent.resolveActivity(Utils.getContext().getPackageManager()) == null ||
            Utils.getContext().getPackageManager().queryIntentActivities(intent, 0).size() == 0);
}
 
开发者ID:Wilshion,项目名称:HeadlineNews,代码行数:16,代码来源:ActivityUtils.java

示例8: doBindService

import android.content.Intent; //导入方法依赖的package包/类
/**
 * Bind this Activity to Android-ROS bridge service
 */
private void doBindService() {
    Intent intent = new Intent();
    intent.setClassName(GUESTSCIENCE_SERVICE_CONTEXT, GUESTSCIENCE_SERVICE_CLASSNAME);
    bindService(intent, mServiceConnection, Context.BIND_AUTO_CREATE);
    mIsBound = true;
    mTextCommStatus.setText("Comm Status: Binded");
    Log.i(LOGTAG, "BINDED to SERVICE!");
}
 
开发者ID:nasa,项目名称:astrobee_android,代码行数:12,代码来源:MainActivity.java

示例9: onOptionsItemSelected

import android.content.Intent; //导入方法依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
  Intent intent = new Intent(Intent.ACTION_VIEW);
  intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
  switch (item.getItemId()) {
    case R.id.menu_settings:
      intent.setClassName(this, PreferencesActivity.class.getName());
      startActivity(intent);
      break;
    default:
      return super.onOptionsItemSelected(item);
  }
  return true;
}
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:15,代码来源:CaptureActivity.java

示例10: bind

import android.content.Intent; //导入方法依赖的package包/类
void bind() {
	Log.v(TAG, "initiating bind to authenticator type " + mAuthenticatorInfo.desc.type);
	Intent intent = new Intent();
	intent.setAction(AccountManager.ACTION_AUTHENTICATOR_INTENT);
	intent.setClassName(mAuthenticatorInfo.serviceInfo.packageName, mAuthenticatorInfo.serviceInfo.name);
	intent.putExtra("_VA_|_user_id_", mUserId);

	if (!mContext.bindService(intent, this, Context.BIND_AUTO_CREATE)) {
		Log.d(TAG, "bind attempt failed for " + toDebugString());
		onError(AccountManager.ERROR_CODE_REMOTE_EXCEPTION, "bind failure");
	}
}
 
开发者ID:codehz,项目名称:container,代码行数:13,代码来源:VAccountManagerService.java

示例11: ifHuaweiAlert

import android.content.Intent; //导入方法依赖的package包/类
private void ifHuaweiAlert() {
    final SharedPreferences settings = getSharedPreferences("ProtectedApps", MODE_PRIVATE);
    final String saveIfSkip = "skipProtectedAppsMessage";
    boolean skipMessage = settings.getBoolean(saveIfSkip, false);
    if (!skipMessage) {
        final SharedPreferences.Editor editor = settings.edit();
        Intent intent = new Intent();
        intent.setClassName("com.huawei.systemmanager", "com.huawei.systemmanager.optimize.process.ProtectActivity");
        if (isCallable(intent)) {
            final AppCompatCheckBox dontShowAgain = new AppCompatCheckBox(this);
            dontShowAgain.setText(R.string.Do_not_show_again);
            dontShowAgain.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                @Override
                public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                    editor.putBoolean(saveIfSkip, isChecked);
                    editor.apply();
                }
            });

            new AlertDialog.Builder(this)
                    .setTitle("Huawei Protected Apps")
                    .setMessage(String.format("%s requires to be enabled in 'Protected Apps' to send notifications.%n", getString(R.string.app_name)))
                    .setView(dontShowAgain)
                    .setPositiveButton("Protected Apps", new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {
                            huaweiProtectedApps();
                        }
                    })
                    .setNegativeButton("Cancel", null)
                    .show();
        } else {
            editor.putBoolean(saveIfSkip, true);
            editor.apply();
        }
    }
}
 
开发者ID:Cesarsk,项目名称:Say_it,代码行数:37,代码来源:MainActivity.java

示例12: run

import android.content.Intent; //导入方法依赖的package包/类
public void run() {
    if (!MiPushClient.shouldUseMIUIPush(this.a) && 1 == a.a(this.a).m()) {
        try {
            List<PackageInfo> installedPackages = this.a.getPackageManager()
                    .getInstalledPackages(4);
            if (installedPackages != null) {
                for (PackageInfo packageInfo : installedPackages) {
                    ServiceInfo[] serviceInfoArr = packageInfo.services;
                    if (serviceInfoArr != null) {
                        for (ServiceInfo serviceInfo : serviceInfoArr) {
                            if (serviceInfo.exported && serviceInfo.enabled && ("com.xiaomi" +
                                    ".mipush.sdk.PushMessageHandler").equals(serviceInfo
                                    .name) && !this.a.getPackageName().equals(serviceInfo
                                    .packageName)) {
                                try {
                                    Thread.sleep(((long) ((Math.random() * PathListView
                                            .ZOOM_X2) + PathListView.NO_ZOOM)) * 1000);
                                } catch (InterruptedException e) {
                                }
                                Intent intent = new Intent();
                                intent.setClassName(serviceInfo.packageName, serviceInfo.name);
                                intent.setAction("com.xiaomi.mipush.sdk.WAKEUP");
                                this.a.startService(intent);
                            }
                        }
                        continue;
                    }
                }
            }
        } catch (Throwable th) {
        }
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:34,代码来源:d.java

示例13: forceOpenGPS

import android.content.Intent; //导入方法依赖的package包/类
/**
 * 强制打开GPS
 * 
 * @param context
 */
public static void forceOpenGPS(Context context) {
	// 4.0++
	if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
		Intent intent = new Intent("android.location.GPS_ENABLED_CHANGE");
		intent.putExtra("enabled", true);
		context.sendBroadcast(intent);

		String provider = Settings.Secure.getString(
				context.getContentResolver(),
				Settings.Secure.LOCATION_PROVIDERS_ALLOWED);
		if (!provider.contains("gps")) { // if gps is disabled
			final Intent poke = new Intent();
			poke.setClassName("com.android.settings",
					"com.android.settings.widget.SettingsAppWidgetProvider");
			poke.addCategory(Intent.CATEGORY_ALTERNATIVE);
			poke.setData(Uri.parse("3"));
			context.sendBroadcast(poke);
		}
	} else {
		Intent GPSIntent = new Intent();
		GPSIntent.setClassName("com.android.settings",
				"com.android.settings.widget.SettingsAppWidgetProvider");
		GPSIntent.addCategory("android.intent.category.ALTERNATIVE");
		GPSIntent.setData(Uri.parse("custom:3"));
		try {
			PendingIntent.getBroadcast(context, 0, GPSIntent, 0).send();
		} catch (CanceledException e) {
		}
	}
}
 
开发者ID:TIIEHenry,项目名称:TIIEHenry-Android-SDK,代码行数:36,代码来源:LocationUtil.java

示例14: onReceive

import android.content.Intent; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
  try {
    if (intent == null) {
      Log.e("Received a null intent.");
      return;
    }
    // Parse manifest and pull metadata which contains client broadcast receiver class.
    String receiver = LeanplumManifestHelper.parseNotificationMetadata();
    // If receiver isn't found we will open up notification with default activity
    if (receiver == null) {
      Log.d("Custom broadcast receiver class not set, using default one.");
      LeanplumPushService.openNotification(context, intent);
    } else {
      Log.d("Custom broadcast receiver class found, using it to handle push notifications.");
      // Forward Intent to a client broadcast receiver.
      Intent forwardIntent = new Intent();
      // Add action to be able to differentiate between multiple intents.
      forwardIntent.setAction(LeanplumPushService.LEANPLUM_NOTIFICATION);
      forwardIntent.setClassName(context, receiver);
      forwardIntent.putExtras(intent.getExtras());
      context.sendBroadcast(forwardIntent);
    }
  } catch (Throwable t) {
    Util.handleException(t);
  }
}
 
开发者ID:Leanplum,项目名称:Leanplum-Android-SDK,代码行数:28,代码来源:LeanplumPushReceiver.java

示例15: isActivityExists

import android.content.Intent; //导入方法依赖的package包/类
/**
 * 判断是否存在Activity
 *
 * @param packageName 包名
 * @param className activity全路径类名
 * @return {@code true}: 是<br>{@code false}: 否
 */
public static boolean isActivityExists(String packageName, String className) {
    Intent intent = new Intent();
    intent.setClassName(packageName, className);
    PackageManager packageManager = ContextUtils.getContext()
                                                .getPackageManager();
    return !(packageManager.resolveActivity(intent, 0) == null ||
                     intent.resolveActivity(packageManager) == null ||
                     packageManager.queryIntentActivities(intent, 0)
                                   .isEmpty());
}
 
开发者ID:imliujun,项目名称:LJFramework,代码行数:18,代码来源:ActivityUtils.java


注:本文中的android.content.Intent.setClassName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。