RePlugin plugin
When the RePlugin framework develops a plug-in, the default title of the activity is the host's application name, which is too inconvenient. Now you need to set the title yourself in the plug-in. The following method can get the real label name of the plug-in activity:
public class RePluginHelper {
//Replugin插件getPluginContext的getPackageName()和正常的getPackageName()返回的是宿主的包名,
//getApplicationInfo()的packageName返回的是插件的包名
public static String getPackageName(Context context){
return context.getApplicationInfo().packageName;
}
/**
* 读取插件的activity的标签名
* @param context
* @return
*/
public static CharSequence getActivityLabel(Activity context){
try {
ActivityInfo activityInfo = context.getPackageManager().getActivityInfo(new ComponentName(getPackageName(context),context.getClass().getCanonicalName()), PackageManager.GET_ACTIVITIES);
CharSequence label = activityInfo.loadLabel(context.getPackageManager());
return label;
} catch (PackageManager.NameNotFoundException e) {
return context.getTitle();
}
}
/**
* 读取插件的应用名
* @param context
* @return
*/
public static CharSequence getAppLabel(Context context){
return context.getApplicationInfo().loadLabel(context.getPackageManager());
}
}