本文整理汇总了Java中android.content.ComponentName.getClassName方法的典型用法代码示例。如果您正苦于以下问题:Java ComponentName.getClassName方法的具体用法?Java ComponentName.getClassName怎么用?Java ComponentName.getClassName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.content.ComponentName
的用法示例。
在下文中一共展示了ComponentName.getClassName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: schedule
import android.content.ComponentName; //导入方法依赖的package包/类
@Override
public int schedule(JobInfo job) throws RemoteException {
int vuid = VBinder.getCallingUid();
int id = job.getId();
ComponentName service = job.getService();
JobId jobId = new JobId(vuid, service.getPackageName(), id);
JobConfig config = mJobStore.get(jobId);
if (config == null) {
config = new JobConfig(mGlobalJobId++, service.getClassName(), job.getExtras());
mJobStore.put(jobId, config);
} else {
config.serviceName = service.getClassName();
config.extras = job.getExtras();
}
saveJobs();
mirror.android.app.job.JobInfo.jobId.set(job, config.virtualJobId);
mirror.android.app.job.JobInfo.service.set(job, mJobProxyComponent);
return mScheduler.schedule(job);
}
示例2: getShortClassName
import android.content.ComponentName; //导入方法依赖的package包/类
public static String getShortClassName(Intent intent) {
if (intent == null) {
return "";
}
ComponentName mComponentName = intent.getComponent();
if (mComponentName == null) {
String mString = intent.getAction();
if (isEmpty(mString)) {
return "";
}
return mString;
}
String mPackageClassName = mComponentName.getClassName();
if (isEmpty(mPackageClassName)) {
return "";
}
return mPackageClassName.substring(mPackageClassName.lastIndexOf(".") + 1);
}
示例3: ServiceRecord
import android.content.ComponentName; //导入方法依赖的package包/类
ServiceRecord(ComponentName cn, Intent.FilterComparison fi, ServiceInfo si) {
name = cn;
plugin = cn.getPackageName();
className = cn.getClassName();
shortName = name.flattenToShortString();
intent = fi;
serviceInfo = si;
}
示例4: whichShare
import android.content.ComponentName; //导入方法依赖的package包/类
public static String whichShare(Intent realIntent){
final String a; //temp
final ComponentName b; //temp
final String c; //temp
if ((a = realIntent.getScheme()) != null) { //使用||的话会莫名其妙的空指针,改成遍历数组
for(String each: TargetIntentSchemes) { //遍历数组
if (each.equals(a)) {
return each;
}
}
}
else if((b = realIntent.getComponent()) != null){ //新微信
final String packageName = b.getPackageName();
final String className = b.getClassName(); //debug用的土方法
if ("com.tencent.mm".equals(packageName) && "com.tencent.mm.plugin.base.stub.WXEntryActivity".equals(className)
&& realIntent.getIntExtra("_wxapi_command_type",0) == 2 //命令1是调用微信登录,只有命令2是分享到微博
)
return "weixin";
}
/*else if((c = realIntent.getAction()) != null){
if("com.sina.weibo.sdk.action.ACTION_WEIBO_ACTIVITY".equals(c))
return "weibo";
}*/
return null; //不是分享
}
示例5: getApp
import android.content.ComponentName; //导入方法依赖的package包/类
public AppLauncher getApp(ComponentName appname) {
String actvname = appname.getClassName();
String pkgname = appname.getPackageName();
AppLauncher appLauncher = null;
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.query(APP_TABLE, appcolumns, ACTVNAME + "=? and " + PKGNAME + "=?", new String[]{actvname, pkgname}, null, null, null);
try {
if (cursor.moveToNext()) { //ACTVNAME, PKGNAME, LABEL, CATID
//pkgname = cursor.getString(1);
String label = cursor.getString(cursor.getColumnIndex(LABEL));
String catID = cursor.getString(cursor.getColumnIndex(CATID));
boolean widget = cursor.getShort(cursor.getColumnIndex(ISWIDGET)) == 1;
String customlabel = cursor.getString(cursor.getColumnIndex(CUSTOMLABEL));
// Log.d("LaunchDB", "getApp " + pkgname + " " + catID);
appLauncher = AppLauncher.createAppLauncher(actvname, pkgname, customlabel==null?label:customlabel, catID, widget);
}
} finally {
cursor.close();
}
return appLauncher;
}
示例6: appHasCustomLabel
import android.content.ComponentName; //导入方法依赖的package包/类
public boolean appHasCustomLabel(ComponentName appname) {
String actvname = appname.getClassName();
String pkgname = appname.getPackageName();
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.query(APP_TABLE, new String [] {CUSTOMLABEL}, ACTVNAME + "=? and " + PKGNAME + "=?", new String[]{actvname, pkgname}, null, null, null);
try {
if (cursor.moveToNext()) { //ACTVNAME, PKGNAME, LABEL, CATID
String customlabel = cursor.getString(cursor.getColumnIndex(CUSTOMLABEL));
if (customlabel!=null && !customlabel.isEmpty()) {
return true;
}
}
} finally {
cursor.close();
}
return false;
}
示例7: getAppCategory
import android.content.ComponentName; //导入方法依赖的package包/类
public String getAppCategory(ComponentName appname) {
String actvname = appname.getClassName();
String pkgname = appname.getPackageName();
String catID = null;
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.query(APP_TABLE, new String[]{CATID}, ACTVNAME + "=? and " + PKGNAME + "=?", new String[]{actvname, pkgname}, null, null, null);
try {
if (cursor.moveToNext()) { //ACTVNAME, PKGNAME, LABEL, CATID
catID = cursor.getString(cursor.getColumnIndex(CATID));
}
} finally {
cursor.close();
}
return catID;
}
示例8: handleCreate
import android.content.ComponentName; //导入方法依赖的package包/类
final void handleCreate(String plugin, Activity activity, String container) {
ComponentName cn = activity.getComponentName();
if (cn != null) {
container = cn.getClassName();
}
if (LOG) {
LogDebug.d(PLUGIN_TAG, "PACM: activity created h=" + activity.hashCode() + " class=" + activity.getClass().getName() + " container=" + container);
}
synchronized (mLock) {
HashMap<String, ActivityState> map = mStates;
ActivityState state = map.get(container);
if (state != null) {
state.create(plugin, activity);
}
}
}
示例9: getAppShortcutInfo
import android.content.ComponentName; //导入方法依赖的package包/类
/**
* Make an ShortcutInfo object for a shortcut that is an application.
*/
public ShortcutInfo getAppShortcutInfo(
Intent intent, boolean allowMissingTarget, boolean useLowResIcon) {
if (user == null) {
return null;
}
ComponentName componentName = intent.getComponent();
if (componentName == null) {
return null;
}
Intent newIntent = new Intent(Intent.ACTION_MAIN, null);
newIntent.addCategory(Intent.CATEGORY_LAUNCHER);
newIntent.setComponent(componentName);
LauncherActivityInfo lai = LauncherAppsCompat.getInstance(mContext)
.resolveActivity(newIntent, user);
if ((lai == null) && !allowMissingTarget) {
return null;
}
final ShortcutInfo info = new ShortcutInfo();
info.itemType = LauncherSettings.Favorites.ITEM_TYPE_APPLICATION;
info.user = user;
info.intent = newIntent;
mIconCache.getTitleAndIcon(info, lai, useLowResIcon);
if (mIconCache.isDefaultIcon(info.iconBitmap, user)) {
Bitmap icon = loadIcon(info);
info.iconBitmap = icon != null ? icon : info.iconBitmap;
}
if (lai != null && PackageManagerHelper.isAppSuspended(lai.getApplicationInfo())) {
info.isDisabled = ShortcutInfo.FLAG_DISABLED_SUSPENDED;
}
// from the db
if (TextUtils.isEmpty(info.title)) {
info.title = getTitle();
}
// fall back to the class name of the activity
if (info.title == null) {
info.title = componentName.getClassName();
}
info.contentDescription = mUserManager.getBadgedLabelForUser(info.title, info.user);
return info;
}
示例10: startActivity
import android.content.ComponentName; //导入方法依赖的package包/类
/**
* 开启一个插件的Activity <p>
* 其中Intent的ComponentName的Key应为插件名(而不是包名),可使用createIntent方法来创建Intent对象
*
* @param context Context对象
* @param intent 要打开Activity的Intent,其中ComponentName的Key必须为插件名
* @return 插件Activity是否被成功打开?
* FIXME 是否需要Exception来做?
* @see #createIntent(String, String)
* @since 1.0.0
*/
public static boolean startActivity(Context context, Intent intent) {
// TODO 先用旧的开启Activity方案,以后再优化
ComponentName cn = intent.getComponent();
if (cn == null) {
// TODO 需要支持Action方案
return false;
}
String plugin = cn.getPackageName();
String cls = cn.getClassName();
return PluginFactory.startActivityWithNoInjectCN(context, intent, plugin, cls, IPluginManager.PROCESS_AUTO);
}
示例11: startUniversalCopy
import android.content.ComponentName; //导入方法依赖的package包/类
private void startUniversalCopy(){
Log.e(TAG,"startUniversalCopy");
Activity topActivity=null;
ActivityManager activityManager= (ActivityManager) mActivities.get(0).getApplication().getSystemService(Context.ACTIVITY_SERVICE);
List<ActivityManager.RunningTaskInfo> taskInfos=activityManager.getRunningTasks(1);
if (taskInfos.size()>0){
ComponentName top=taskInfos.get(0).topActivity;
if (top!=null){
String name=top.getClassName();
for (Activity activity:mActivities){
if (activity.getClass().getName().equals(name)){
topActivity=activity;
break;
}
}
}
}
if (topActivity==null){
if (mActivities.size()>0) {
topActivity = mActivities.get(mActivities.size() - 1);
if (topActivity.isFinishing()){
topActivity=null;
}
}
}
UniversalCopy(topActivity);
}
示例12: getTopActivityName
import android.content.ComponentName; //导入方法依赖的package包/类
/**
* <一句话功能简述> 获取最上层的Activity包名
*
* @Description<功能详细描述>
*
* @param context
* @return
* @LastModifiedDate:2015-9-6
* @author rqj
* @EditHistory:<修改内容><修改人>
*/
public static String getTopActivityName(Context context) {
String topActivityClassName = null;
ActivityManager activityManager = (ActivityManager) (context
.getSystemService(android.content.Context.ACTIVITY_SERVICE));
List<RunningTaskInfo> runningTaskInfos = activityManager
.getRunningTasks(1);
if (runningTaskInfos != null) {
ComponentName f = runningTaskInfos.get(0).topActivity;
topActivityClassName = f.getClassName();
}
return topActivityClassName;
}
示例13: startActivityForResultCompat
import android.content.ComponentName; //导入方法依赖的package包/类
/**
* 如果 replugin-host-lib 版本小于 2.1.3,使用此 compat 方法。
*/
private static boolean startActivityForResultCompat(Activity activity, Intent intent, int requestCode, Bundle options) {
String plugin = getPluginName(activity, intent);
if (LogDebug.LOG) {
LogDebug.d(TAG, "start activity with startActivityForResult: intent=" + intent);
}
if (TextUtils.isEmpty(plugin)) {
return false;
}
ComponentName cn = intent.getComponent();
if (cn == null) {
return false;
}
String name = cn.getClassName();
ComponentName cnNew = loadPluginActivity(intent, plugin, name, IPluginManager.PROCESS_AUTO);
if (cnNew == null) {
return false;
}
intent.setComponent(cnNew);
if (Build.VERSION.SDK_INT >= 16) {
activity.startActivityForResult(intent, requestCode, options);
} else {
activity.startActivityForResult(intent, requestCode);
}
return true;
}
示例14: makeCompname
import android.content.ComponentName; //导入方法依赖的package包/类
private String makeCompname(ComponentName componentName) {
return componentName.getPackageName() + "/" + componentName.getClassName();
}
示例15: buildComponentString
import android.content.ComponentName; //导入方法依赖的package包/类
private String buildComponentString(ComponentName component) {
return component.getPackageName() + " " + component.getClassName();
}