Java Code Examples for android.content.ComponentName.getClassName()

The following are Jave code examples for showing how to use getClassName() of the android.content.ComponentName class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: container   File: VJobSchedulerService.java   Source Code and License Vote up 6 votes
@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);
}
 
Example 2
Project: letv   File: TextUtils.java   Source Code and License Vote up 6 votes
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);
}
 
Example 3
Project: springreplugin   File: ServiceRecord.java   Source Code and License Vote up 6 votes
ServiceRecord(ComponentName cn, Intent.FilterComparison fi, ServiceInfo si) {
    name = cn;
    plugin = cn.getPackageName();
    className = cn.getClassName();
    shortName = name.flattenToShortString();
    intent = fi;
    serviceInfo = si;
}
 
Example 4
Project: PretendSharing_Xposed   File: Detector.java   Source Code and License Vote up 6 votes
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; //不是分享
}
 
Example 5
Project: LaunchTime   File: DB.java   Source Code and License Vote up 6 votes
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;
    }
 
Example 6
Project: LaunchTime   File: DB.java   Source Code and License Vote up 6 votes
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;
}
 
Example 7
Project: LaunchTime   File: DB.java   Source Code and License Vote up 6 votes
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;
}
 
Example 8
Project: springreplugin   File: PluginContainers.java   Source Code and License Vote up 6 votes
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);
        }
    }
}
 
Example 9
Project: VirtualHook   File: VJobSchedulerService.java   Source Code and License Vote up 6 votes
@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);
}
 
Example 10
Project: LaunchEnr   File: LoaderCursor.java   Source Code and License Vote up 5 votes
/**
 * 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;
}
 
Example 11
Project: springreplugin   File: RePlugin.java   Source Code and License Vote up 5 votes
/**
 * 开启一个插件的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);
}
 
Example 12
Project: Bigbang   File: XposedUniversalCopyHandler.java   Source Code and License Vote up 5 votes
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);
}
 
Example 13
Project: amap   File: AppPackageUtil.java   Source Code and License Vote up 5 votes
/**
 * <一句话功能简述> 获取最上层的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;
}
 
Example 14
Project: springreplugin   File: RePluginInternal.java   Source Code and License Vote up 5 votes
/**
 * 如果 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;
}
 
Example 15
Project: LaunchTime   File: FeedbackActivity.java   Source Code and License Vote up 4 votes
private String makeCompname(ComponentName componentName) {
    return componentName.getPackageName() + "/" + componentName.getClassName();
}
 
Example 16
Project: FlickLauncher   File: PredictiveAppsProvider.java   Source Code and License Vote up 4 votes
private String buildComponentString(ComponentName component) {
    return component.getPackageName() + " " + component.getClassName();
}
 
Example 17
Project: LaunchTime   File: MainActivity.java   Source Code and License Vote up 3 votes
private void addWidget(AppWidgetHostView appwid) {
    if (mChildLock) return;

    ComponentName cn = appwid.getAppWidgetInfo().provider;
    String actvname = cn.getClassName();
    String pkgname = cn.getPackageName();

    String catId = db().getAppCategory(cn);
    if (catId == null || catId.equals(mCategory)) {

        //Log.d(TAG, actvname + " " + pkgname);

        mLoadedWidgets.put(actvname, appwid);

        String label = pkgname;

        AppLauncher.removeAppLauncher(cn);
        AppLauncher app = AppLauncher.createAppLauncher(actvname, pkgname, label, mCategory, true);

        db().addApp(app);
        db().addAppCategoryOrder(mCategory, app.getComponentName());
    } else {
        Toast.makeText(this, getString(R.string.widget_alreay,db().getCategoryDisplay(catId)), Toast.LENGTH_LONG).show();
    }


}
 
Example 18
Project: LaunchTime   File: DB.java   Source Code and License Vote up 3 votes
public void deleteAppLaunchedRecord(ComponentName appname) {

        String actvname = appname.getClassName();
        String pkgname =  appname.getPackageName();

        SQLiteDatabase db = this.getWritableDatabase();


        db.delete(APP_HISTORY_TABLE, ACTVNAME + "=? and " + PKGNAME + "=?", new String[]{actvname, pkgname});

    }
 
Example 19
Project: LaunchTime   File: SpecialIconStore.java   Source Code and License Vote up 3 votes
private static String makeSafeName(ComponentName cname, IconType iconType) {
    String name = cname.getPackageName() + ":" + cname.getClassName();

    String fname = makeSafeName(name);
    if (iconType!=null) fname += "." + iconType.name();

    fname +=  ".png";

    return fname;
}
 
Example 20
Project: android-WearComplicationProvidersTestSuite   File: ComplicationToggleReceiver.java   Source Code and License Vote up 2 votes
/**
 * Returns the key for the shared preference used to hold the current state of a given
 * complication.
 */
static String getPreferenceKey(ComponentName provider, int complicationId) {
    return provider.getClassName() + complicationId;
}