本文整理匯總了Java中android.widget.RemoteViews.getPackage方法的典型用法代碼示例。如果您正苦於以下問題:Java RemoteViews.getPackage方法的具體用法?Java RemoteViews.getPackage怎麽用?Java RemoteViews.getPackage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.widget.RemoteViews
的用法示例。
在下文中一共展示了RemoteViews.getPackage方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: hackRemoteViews
import android.widget.RemoteViews; //導入方法依賴的package包/類
private void hackRemoteViews(RemoteViews remoteViews) throws IllegalAccessException, ClassNotFoundException, NoSuchMethodException, InvocationTargetException {
if (remoteViews != null && !TextUtils.equals(remoteViews.getPackage(), mHostContext.getPackageName())) {
if (sSystemLayoutResIds.containsKey(remoteViews.getLayoutId())) {
Object mActionsObj = FieldUtils.readField(remoteViews, "mActions");
if (mActionsObj instanceof Collection) {
Collection mActions = (Collection) mActionsObj;
String aPackage = remoteViews.getPackage();
Application pluginContent = PluginProcessManager.getPluginContext(aPackage);
if (pluginContent != null) {
Iterator iterable = mActions.iterator();
Class TextViewDrawableActionClass = null;
try {
if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) {
TextViewDrawableActionClass = Class.forName(RemoteViews.class.getName() + "$TextViewDrawableAction");
}
} catch (ClassNotFoundException e) {
}
Class ReflectionActionClass = Class.forName(RemoteViews.class.getName() + "$ReflectionAction");
while (iterable.hasNext()) {
Object action = iterable.next();
if (ReflectionActionClass.isInstance(action)) {//???這裏這樣是對的麽?
String methodName = (String) FieldUtils.readField(action, "methodName");
//String methodName;,int type; Object value;
if ("setImageResource".equals(methodName)) { //setInt(viewId, "setImageResource", srcId);
Object BITMAP = FieldUtils.readStaticField(action.getClass(), "BITMAP");
int resId = (Integer) FieldUtils.readField(action, "value");
Bitmap bitmap = BitmapFactory.decodeResource(pluginContent.getResources(), resId);
FieldUtils.writeField(action, "type", BITMAP);
FieldUtils.writeField(action, "value", bitmap);
FieldUtils.writeField(action, "methodName", "setImageBitmap");
} else if ("setImageURI".equals(methodName)) {//setUri(viewId, "setImageURI", uri);
iterable.remove(); //TODO RemoteViews.setImageURI 其實應該適配的。
} else if ("setLabelFor".equals(methodName)) {
iterable.remove(); //TODO RemoteViews.setLabelFor 其實應該適配的。
}
} else if (TextViewDrawableActionClass != null && TextViewDrawableActionClass.isInstance(action)) {
iterable.remove();
// if ("setTextViewCompoundDrawables".equals(methodName)) {
// iterable.remove(); //TODO RemoteViews.setTextViewCompoundDrawables 其實應該適配的。
// } else if ("setTextViewCompoundDrawablesRelative".equals(methodName)) {
// iterable.remove(); //TODO RemoteViews.setTextViewCompoundDrawablesRelative 其實應該適配的。
// }
}
}
}
}
}
if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
FieldUtils.writeField(remoteViews, "mApplication", mHostContext.getApplicationInfo());
} else {
FieldUtils.writeField(remoteViews, "mPackage", mHostContext.getPackageName());
}
}
}