public static void updateMenuEntries(Context context, Menu menu, String pkgName) { if (context.getPackageManager().getLaunchIntentForPackage(pkgName) == null) { menu.findItem(R.id.menu_app_launch).setEnabled(false); Drawable icon = menu.findItem(R.id.menu_app_launch).getIcon().mutate(); icon.setColorFilter(Color.GRAY, Mode.SRC_IN); menu.findItem(R.id.menu_app_launch).setIcon(icon); } boolean hasMarketLink = false; try { PackageManager pm = context.getPackageManager(); String installer = pm.getInstallerPackageName(pkgName); if (installer != null) hasMarketLink = installer.equals("com.android.vending") || installer.contains("google"); } catch (Exception e) { } menu.findItem(R.id.menu_app_store).setEnabled(hasMarketLink); try { Resources res = context.createPackageContext("com.android.vending", 0).getResources(); int id = res.getIdentifier("ic_launcher_play_store", "mipmap", "com.android.vending"); Drawable icon = res.getDrawable(id); if (!hasMarketLink) { icon = icon.mutate(); icon.setColorFilter(Color.GRAY, Mode.SRC_IN); } menu.findItem(R.id.menu_app_store).setIcon(icon); } catch (Exception e) { } }
// set wallpaper as background private void setBackground(Context bcontext, ViewGroup layout) { // Settings.System.LOCKSCREEN_BACKGROUND String mLockBack = Settings.System.getString(bcontext.getContentResolver(), "lockscreen_background"); if (mLockBack != null) { if (!mLockBack.isEmpty()) { try { layout.setBackgroundColor(Integer.parseInt(mLockBack)); } catch (NumberFormatException e) { } } else { String lockWallpaper = ""; try { lockWallpaper = bcontext.createPackageContext("com.cyanogenmod.cmparts", 0).getFilesDir() + "/lockwallpaper"; } catch (NameNotFoundException e1) { } if (!lockWallpaper.isEmpty()) { Bitmap lockb = BitmapFactory.decodeFile(lockWallpaper); layout.setBackgroundDrawable(new BitmapDrawable(lockb)); } } } }
public void testSharedCache() throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidKeySpecException, KeyStoreException, CertificateException, NoSuchProviderException, InvalidAlgorithmParameterException, UnrecoverableEntryException, DigestException, IllegalBlockSizeException, BadPaddingException, IOException, NameNotFoundException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException { AuthenticationSettings.INSTANCE.setSharedPrefPackageName("mockpackage"); StorageHelper mockSecure = mock(StorageHelper.class); Context mockContext = mock(Context.class); Context packageContext = mock(Context.class); SharedPreferences prefs = mock(SharedPreferences.class); when(prefs.contains("testkey")).thenReturn(true); when(prefs.getString("testkey", "")).thenReturn("test_encrypted"); when(mockSecure.decrypt("test_encrypted")).thenReturn("{\"mClientId\":\"clientId23\"}"); when(mockContext.createPackageContext("mockpackage", Context.MODE_PRIVATE)) .thenReturn(packageContext); when(packageContext.getSharedPreferences("com.microsoft.aad.adal.cache", Activity.MODE_PRIVATE)) .thenReturn(prefs); Class<?> c = DefaultTokenCacheStore.class; Field encryptHelper = c.getDeclaredField("sHelper"); encryptHelper.setAccessible(true); encryptHelper.set(null, mockSecure); DefaultTokenCacheStore cache = new DefaultTokenCacheStore(mockContext); TokenCacheItem item = cache.getItem("testkey"); // Verify returned item assertEquals("Same item as mock", "clientId23", item.getClientId()); encryptHelper.set(null, null); }
public Drawable getDrawable(int i) { Object obj; Resources resources; try { resources = mContext.createPackageContext("com.google.android.gms", 4).getResources(); } // Misplaced declaration of an exception variable catch (Object obj) { return null; } switch (i) { case 2: // '\002' obj = "ic_plusone_tall"; break; default: obj = "ic_plusone_standard"; break; case 0: // '\0' obj = "ic_plusone_small"; break; case 1: // '\001' obj = "ic_plusone_medium"; break; } goto _L1
/* package */ Class<?> getPluginClass(String packageName, String className) throws NameNotFoundException, ClassNotFoundException { Context pluginContext = mContext.createPackageContext( packageName, Context.CONTEXT_INCLUDE_CODE | Context.CONTEXT_IGNORE_SECURITY); ClassLoader pluginCL = pluginContext.getClassLoader(); return pluginCL.loadClass(className); }
public static Context b(Context context) { try { context = context.createPackageContext(a(context), 3); } // Misplaced declaration of an exception variable catch (Context context) { return null; } return context; }
public static void load(Context ctx, String pkg) throws NameNotFoundException, XmlPullParserException, IOException { sPackageName = pkg; Context extCtx = ctx.createPackageContext(pkg, Context.CONTEXT_IGNORE_SECURITY); sRes = extCtx.getResources(); int id = sRes.getIdentifier("appfilter", "xml", sPackageName); boolean loadFromAssets = false; if (id != 0) { sParser = sRes.getXml(id); } else { loadFromAssets = true; Log.e( TAG, "Failed to get appfilter.xml from resources of package " + sPackageName + ", attempting load from assets..."); } if (loadFromAssets) { InputStream is = sRes.getAssets().open("appfilter.xml"); sParser = XmlPullParserFactory.newInstance().newPullParser(); sParser.setInput(is, null); } if (sParser == null) throw new XmlPullParserException("Parser is null!"); SharedPreferences prefs = ctx.getSharedPreferences("icon_pack", Context.MODE_PRIVATE); prefs.edit().clear().commit(); SharedPreferences.Editor editor = prefs.edit(); while (sParser.getEventType() != XmlPullParser.END_DOCUMENT) { int type = sParser.getEventType(); switch (type) { case XmlPullParser.START_TAG: String currentComponent = sParser.getAttributeValue(null, "component"); String drawable = sParser.getAttributeValue(null, "drawable"); if (currentComponent != null) { ComponentName cmpName = ComponentNameParser.parse(currentComponent); if (cmpName != null && drawable != null) { int drawableId = sRes.getIdentifier(drawable, "drawable", sPackageName); if (drawableId != 0) { // TODO: replace by SQL database String pref = cmpName.getPackageName() + "/" + cmpName.getClassName(); editor.putInt(pref, drawableId); } } } break; } sParser.next(); } editor.commit(); }
public boolean isInstalled(String packageName) { boolean isInstalled = false; try { context.createPackageContext(packageName, Context.CONTEXT_IGNORE_SECURITY); isInstalled = true; } catch (NameNotFoundException e) { if (Constants.DEBUG) Log.e(TAG, e.getMessage(), e); } return isInstalled; }
public static String getShareprefer( Context context, String packageName, String tableName, String name) { try { Context mComtext = context.createPackageContext(packageName, Context.CONTEXT_IGNORE_SECURITY); SharedPreferences sp = mComtext.getSharedPreferences(tableName, Context.MODE_WORLD_READABLE); return sp.getString(name, "获取不到"); } catch (NameNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; }
@Override public void onReceive(Context context, Intent intent) { try { if (PreferenceManager.getDefaultSharedPreferences( context.createPackageContext(Strings.PACKAGE, 0)) .getBoolean(Strings.SETTINGS_REFRESHENABLED, false)) { context.startService(new Intent(context, RefreshService.class)); } context.sendBroadcast(new Intent(Strings.ACTION_UPDATEWIDGET)); } catch (NameNotFoundException e) { } }
public static Context getModContext(Context context) { Context modContext = null; try { if (context.getPackageName().equals(FTD.PACKAGE_NAME)) { modContext = context; } else { modContext = context.createPackageContext(FTD.PACKAGE_NAME, Context.CONTEXT_IGNORE_SECURITY); } } catch (Throwable t) { } return modContext; }
/** * Build a {@link Context} cloned into another package name, usually for the purposes of reading * remote resources. */ private Context getRemoteContext(RemoteViews views) { // Bail if missing package name final String packageName = views.getPackage(); if (packageName == null) return mContext; try { // Return if cloned successfully, otherwise default return mContext.createPackageContext(packageName, Context.CONTEXT_RESTRICTED); } catch (NameNotFoundException e) { Log.e(TAG, "Package name " + packageName + " not found"); return mContext; } }
protected Context getPackageContext(Context context, String packageName) { Context packageContext = null; if (StringUtil.isEmpty(packageName)) { return packageContext; } try { packageContext = context.createPackageContext(packageName, Context.CONTEXT_IGNORE_SECURITY); } catch (NameNotFoundException e) { if (Constants.DEBUG) Log.e(TAG, e.getMessage(), e); } return packageContext; }
/** Inflate and return the default layout requested by AppWidget provider. */ protected View getDefaultView() { if (LOGD) { Log.d(TAG, "getDefaultView"); } View defaultView = null; Exception exception = null; try { if (mInfo != null) { Context theirContext = mContext.createPackageContext( mInfo.provider.getPackageName(), Context.CONTEXT_RESTRICTED); mRemoteContext = theirContext; LayoutInflater inflater = (LayoutInflater) theirContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); inflater = inflater.cloneInContext(theirContext); inflater.setFilter(sInflaterFilter); AppWidgetManager manager = AppWidgetManager.getInstance(mContext); Bundle options = manager.getAppWidgetOptions(mAppWidgetId); int layoutId = mInfo.initialLayout; if (options.containsKey(AppWidgetManager.OPTION_APPWIDGET_HOST_CATEGORY)) { int category = options.getInt(AppWidgetManager.OPTION_APPWIDGET_HOST_CATEGORY); if (category == AppWidgetProviderInfo.WIDGET_CATEGORY_KEYGUARD) { int kgLayoutId = mInfo.initialKeyguardLayout; // If a default keyguard layout is not specified, use the standard // default layout. layoutId = kgLayoutId == 0 ? layoutId : kgLayoutId; } } defaultView = inflater.inflate(layoutId, this, false); } else { Log.w(TAG, "can't inflate defaultView because mInfo is missing"); } } catch (PackageManager.NameNotFoundException e) { exception = e; } catch (RuntimeException e) { exception = e; } if (exception != null) { Log.w(TAG, "Error inflating AppWidget " + mInfo + ": " + exception.toString()); } if (defaultView == null) { if (LOGD) Log.d(TAG, "getDefaultView couldn't find any view, so inflating error"); defaultView = getErrorView(); } return defaultView; }
@Nullable public final Context getPackageContext() { Context c = mPackageContext.get(); if (c == null) { try { c = mAskAppContext.createPackageContext(mPackageName, Context.CONTEXT_IGNORE_SECURITY); mPackageContext = new WeakReference<>(c); } catch (NameNotFoundException e) { Logger.w(TAG, "Failed to find package %s!", mPackageName); Logger.w(TAG, "Failed to find package! ", e); } } return c; }
public String getPf(String pName, String key) { Context otherAppsContext; String value = null; try { otherAppsContext = context.createPackageContext(pName, Context.CONTEXT_IGNORE_SECURITY); SharedPreferences sharedPreferences = otherAppsContext.getSharedPreferences("pf", Context.MODE_WORLD_READABLE); value = sharedPreferences.getString(key, ""); } catch (NameNotFoundException e) { e.printStackTrace(); } return value; }
public app2class1(Context context) { try { Log.i(LOG, "--app2class1() called."); Context mmsCtx = context.createPackageContext( "com.example.app1", Context.CONTEXT_INCLUDE_CODE | Context.CONTEXT_IGNORE_SECURITY); Class<?> cl = Class.forName("com.example.app1.app1class1", true, mmsCtx.getClassLoader()); Log.i(LOG, "--getCanonicalName()= " + cl.getCanonicalName()); // cl.getMethod("init", Context.class).invoke(null, mmsCtx); app1Method = cl.getMethod("getString", String.class); Log.i(LOG, "--getMethod got a method"); app1Object = cl.getMethod("getInstance").invoke((Object[]) null); // Method app1Metho2 = cl.getm Log.i(LOG, "--getInstance passed"); // app1Object = cl.getMethod("getInstance").invoke("s"); // cl.getMethod("getString", String.class).invoke(cl, // " static method invocation worked "); // // app1Method = cl.getMethod("voidMethod", Void.class); } catch (NameNotFoundException ex) { Log.e(LOG, "--constructor() created NameNotFoundException: " + ex.getMessage()); } catch (ClassNotFoundException ex) { // TODO Auto-generated catch block Log.e(LOG, "--constructor() created ClassNotFoundException: " + ex.getMessage()); } catch (NoSuchMethodException ex) { // TODO Auto-generated catch block Log.e(LOG, "--constructor() created NoSuchMethodException: " + ex.getMessage()); } catch (IllegalArgumentException ex) { // TODO Auto-generated catch block Log.e(LOG, "--constructor() created IllegalArgumentException: " + ex.getMessage()); } catch (IllegalAccessException ex) { // TODO Auto-generated catch block Log.e(LOG, "--constructor() created IllegalAccessException: " + ex.getMessage()); } catch (InvocationTargetException ex) { // TODO Auto-generated catch block Log.e(LOG, "--constructor() created InvocationTargetException: " + ex.getMessage()); } catch (Exception ex) { Log.e(LOG, "--constructor() created Exception: " + ex.getMessage()); } }
public static Drawable getIconForComponent(Context ctx, String component) { if (sRes == null) { Context extCtx; try { extCtx = ctx.createPackageContext( ShortcutsResolver.getExternalIconPackName(ctx), Context.CONTEXT_IGNORE_SECURITY); sRes = extCtx.getResources(); } catch (NameNotFoundException e) { return null; } } int id = ctx.getSharedPreferences("icon_pack", Context.MODE_PRIVATE).getInt(component, 0); if (id == 0) return null; return sRes.getDrawable(id); }
@Override public void registerHostContext(Context context, Bundle args, String commd) { if (!ContactPluginDefault.COMMD_FOR_OP01.equals(commd)) { return; } mContextHost = context; try { mContext = context.createPackageContext( "com.mediatek.op01.plugin", Context.CONTEXT_INCLUDE_CODE | Context.CONTEXT_IGNORE_SECURITY); } catch (NameNotFoundException e) { Log.d(TAG, "no com.mediatek.op01.plugin packages"); } }
/** * Queries the {@link android.content.pm.PackageManager} for any installed {@link * com.battlelancer.seriesguide.api.SeriesGuideExtension} extensions. Their info is extracted into * {@link com.battlelancer.seriesguide.extensions.ExtensionManager.Extension} objects. */ public List<Extension> queryAllAvailableExtensions() { Intent queryIntent = new Intent(SeriesGuideExtension.ACTION_SERIESGUIDE_EXTENSION); PackageManager pm = mContext.getPackageManager(); List<ResolveInfo> resolveInfos = pm.queryIntentServices(queryIntent, PackageManager.GET_META_DATA); List<Extension> extensions = new ArrayList<>(); for (ResolveInfo info : resolveInfos) { Extension extension = new Extension(); // get label, icon and component name extension.label = info.loadLabel(pm).toString(); extension.icon = info.loadIcon(pm); extension.componentName = new ComponentName(info.serviceInfo.packageName, info.serviceInfo.name); // get description Context packageContext; try { packageContext = mContext.createPackageContext(extension.componentName.getPackageName(), 0); Resources packageRes = packageContext.getResources(); extension.description = packageRes.getString(info.serviceInfo.descriptionRes); } catch (SecurityException | PackageManager.NameNotFoundException | Resources.NotFoundException e) { Timber.e(e, "Reading description for extension " + extension.componentName + " failed"); extension.description = ""; } // get (optional) settings activity Bundle metaData = info.serviceInfo.metaData; if (metaData != null) { String settingsActivity = metaData.getString("settingsActivity"); if (!TextUtils.isEmpty(settingsActivity)) { extension.settingsActivity = ComponentName.unflattenFromString( info.serviceInfo.packageName + "/" + settingsActivity); } } Timber.d( "queryAllAvailableExtensions: found extension " + extension.label + " " + extension.componentName); extensions.add(extension); } return extensions; }
/** * Get a color value from a theme attribute. * * @param context used for getting the color. * @param attribute theme attribute. * @param defaultColor default to use. * @return color value */ public static int getThemeColor(Context context, int attribute, int defaultColor) { int themeColor = 0; String packageName = context.getPackageName(); try { Context packageContext = context.createPackageContext(packageName, 0); ApplicationInfo applicationInfo = context.getPackageManager().getApplicationInfo(packageName, 0); packageContext.setTheme(applicationInfo.theme); Resources.Theme theme = packageContext.getTheme(); TypedArray ta = theme.obtainStyledAttributes(new int[] {attribute}); themeColor = ta.getColor(0, defaultColor); ta.recycle(); } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } return themeColor; }
private boolean checkCorePackage() { if (mWrapperContext == null) { Log.d(TAG, "No application context"); mCoreStatus = XWalkLibraryInterface.STATUS_NOT_FOUND; return false; } if (!XWalkAppVersion.VERIFY_XWALK_APK) { Log.d(TAG, "Not verifying the package integrity of Crosswalk runtime library"); } else { try { PackageInfo packageInfo = mWrapperContext .getPackageManager() .getPackageInfo(XWALK_APK_PACKAGE, PackageManager.GET_SIGNATURES); if (!verifyPackageInfo( packageInfo, XWalkAppVersion.XWALK_APK_HASH_ALGORITHM, XWalkAppVersion.XWALK_APK_HASH_CODE)) { mCoreStatus = XWalkLibraryInterface.STATUS_SIGNATURE_CHECK_ERROR; return false; } } catch (NameNotFoundException e) { Log.d(TAG, "Crosswalk package not found"); mCoreStatus = XWalkLibraryInterface.STATUS_NOT_FOUND; return false; } } try { mBridgeContext = mWrapperContext.createPackageContext( XWALK_APK_PACKAGE, Context.CONTEXT_INCLUDE_CODE | Context.CONTEXT_IGNORE_SECURITY); Log.d(TAG, "Created bridge context"); } catch (NameNotFoundException e) { Log.d(TAG, "Crosswalk package not found"); mCoreStatus = XWalkLibraryInterface.STATUS_NOT_FOUND; return false; } return true; }
@Override public void onReceive(Context context, final Intent intent) { if (((TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE)).getCallState() != TelephonyManager.CALL_STATE_IDLE) { return; } Log.v("SMN", "sms"); final Bundle bundle = intent.getExtras(); final Object[] pdusObj = (Object[]) bundle.get("pdus"); final SmsMessage[] messages = new SmsMessage[pdusObj.length]; for (int i = 0; i < pdusObj.length; i++) { messages[i] = SmsMessage.createFromPdu((byte[]) pdusObj[i]); } final StringBuilder sb = new StringBuilder(); if (messages.length > 1) { for (final SmsMessage currentMessage : messages) { sb.append(currentMessage.getDisplayMessageBody()); sb.append('\n'); } } else { sb.append(messages[0].getDisplayMessageBody()); } try { context = context.createPackageContext("org.mailboxer.saymyname", 0); } catch (final NameNotFoundException e) { e.printStackTrace(); } final Intent serviceIntent = new Intent(context, ManagerService.class); serviceIntent.putExtra( "org.mailboxer.saymyname.number", messages[0].getDisplayOriginatingAddress()); serviceIntent.putExtra("org.mailboxer.saymyname.message", sb.toString()); context.startService(serviceIntent); }
/** * Returns an indicator to be drawn. If null is returned, no space for the indicator will be * made. * * @param context the context of the Activity this Action belongs to * @return an indicator to draw or null if no indicator space should exist. */ public Drawable getIndicator(Context context) { if (mDrawableResource == NO_DRAWABLE) { return null; } if (mResourcePackageName == null) { return context.getResources().getDrawable(mDrawableResource); } // If we get to here, need to load the resources. Drawable icon = null; try { Context packageContext = context.createPackageContext(mResourcePackageName, 0); icon = packageContext.getResources().getDrawable(mDrawableResource); } catch (PackageManager.NameNotFoundException e) { if (Log.isLoggable(TAG, Log.WARN)) { Log.w(TAG, "No icon for this action."); } } catch (Resources.NotFoundException e) { if (Log.isLoggable(TAG, Log.WARN)) { Log.w(TAG, "No icon for this action."); } } return icon; }
@Override public Object getItem(int position) { if (mDataValid && mCursor.moveToPosition(position)) { final String title = mCursor.getString(Index.COLUMN_INDEX_TITLE); final String summaryOn = mCursor.getString(Index.COLUMN_INDEX_SUMMARY_ON); final String summaryOff = mCursor.getString(Index.COLUMN_INDEX_SUMMARY_OFF); final String entries = mCursor.getString(Index.COLUMN_INDEX_ENTRIES); final String iconResStr = mCursor.getString(Index.COLUMN_INDEX_ICON); final String className = mCursor.getString(Index.COLUMN_INDEX_CLASS_NAME); final String packageName = mCursor.getString(Index.COLUMN_INDEX_INTENT_ACTION_TARGET_PACKAGE); final String key = mCursor.getString(Index.COLUMN_INDEX_KEY); Context packageContext; if (TextUtils.isEmpty(className) && !TextUtils.isEmpty(packageName)) { packageContext = mContextMap.get(packageName); if (packageContext == null) { try { packageContext = mContext.createPackageContext(packageName, 0); } catch (PackageManager.NameNotFoundException e) { Log.e(LOG_TAG, "Cannot create Context for package: " + packageName); return null; } mContextMap.put(packageName, packageContext); } } else { packageContext = mContext; } final int iconResId = TextUtils.isEmpty(iconResStr) ? R.drawable.empty_icon : Integer.parseInt(iconResStr); return new SearchResult( packageContext, title, summaryOn, summaryOff, entries, iconResId, key); } return null; }
private static String idDebugString(Context baseContext, String packageName, int id) { Context c = null; if (packageName != null) { try { c = baseContext.createPackageContext(packageName, 0); } catch (NameNotFoundException e) { c = baseContext; } } else { c = baseContext; } String pkg; String type; String name; Resources r = c.getResources(); try { return r.getResourceName(id); } catch (Resources.NotFoundException e) { return "<name unknown>"; } }
@Override public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { /* final int N = appWidgetIds.length; // Perform this loop procedure for each App Widget that belongs to this // provider for (int i = 0; i < N; i++) { int appWidgetId = appWidgetIds[i]; // Create an Intent to launch UpdateService Intent intent = new Intent(context, UpdateService.class); PendingIntent pendingIntent = PendingIntent.getService(context, 0, intent, 0); // Get the layout for the App Widget and attach an on-click listener // to the button RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.activity_main); views.setOnClickPendingIntent(R.id.button, pendingIntent); // Tell the AppWidgetManager to perform an update on the current App // Widget appWidgetManager.updateAppWidget(appWidgetId, views); } */ MainActivity.mycontext = context; // Timer timer = new Timer(); // timer.scheduleAtFixedRate(new MyTime(context, appWidgetManager), 1, // 1000); RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.activity_main); Context ctx = null; try { // creating context from mainAPP for accessing database ctx = mycontext.createPackageContext("com.diyapp.kreator2", Context.CONTEXT_IGNORE_SECURITY); if (ctx == null) { Log.v("fake", "failed to get db"); } else { Log.v("fake", "got db"); } } catch (PackageManager.NameNotFoundException e) { // package not found Log.e("Error", e.getMessage()); } System.out.println("ONUPDATE"); mDbHelper = new DiyDbAdapter(ctx); mDbHelper.open(); int i = 0; Cursor c = mDbHelper.fetchAllDiy(); if (c.moveToFirst()) { do { for (String column : DiyDbAdapter.COLUMNS) { opisy[i] = c.getString(c.getColumnIndexOrThrow(DiyDbAdapter.KEY_DESCRIPTION)); aktywnosci[i] = c.getString(c.getColumnIndexOrThrow(DiyDbAdapter.KEY_TITLE)); // SSID_szukane = // c.getString(c.getColumnIndexOrThrow(DiyDbAdapter.KEY_TRIGGER_WIFI_PARAM_SSID)); } i++; } while (c.moveToNext()); } views.setTextViewText(R.id.widget_textview0, top); views.setTextViewText(R.id.widget_textview1, "opis pocz�tkowy"); views.setTextViewText(R.id.widget_textview2, aktywnosci[0]); views.setTextViewText(R.id.widget_textview3, aktywnosci[1]); views.setTextViewText(R.id.widget_textview4, aktywnosci[2]); views.setTextViewText(R.id.widget_textview5, aktywnosci[3]); views.setOnClickPendingIntent(R.id.widget_textview2, buildButtonPendingIntent(context, 0)); views.setOnClickPendingIntent(R.id.widget_textview3, buildButtonPendingIntent(context, 1)); views.setOnClickPendingIntent(R.id.widget_textview4, buildButtonPendingIntent(context, 2)); views.setOnClickPendingIntent(R.id.widget_textview5, buildButtonPendingIntent(context, 3)); pushWidgetUpdate(context, views); }
@Override public View newView(Context context, Cursor cursor, ViewGroup viewGroup) { View v = null; final ViewHolder holder = new ViewHolder(); if (settings.addonTheme) { try { Context viewContext = null; if (res == null) { res = context.getPackageManager().getResourcesForApplication(settings.addonThemePackage); } try { viewContext = context.createPackageContext( settings.addonThemePackage, Context.CONTEXT_IGNORE_SECURITY); } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } if (res != null && viewContext != null) { int id = res.getIdentifier("person", "layout", settings.addonThemePackage); v = LayoutInflater.from(viewContext).inflate(res.getLayout(id), null); holder.name = (TextView) v.findViewById(res.getIdentifier("name", "id", settings.addonThemePackage)); holder.screenName = (TextView) v.findViewById( res.getIdentifier("screen_name", "id", settings.addonThemePackage)); holder.background = (LinearLayout) v.findViewById(res.getIdentifier("background", "id", settings.addonThemePackage)); holder.picture = (ImageView) v.findViewById( res.getIdentifier("profile_pic", "id", settings.addonThemePackage)); } } catch (Exception e) { e.printStackTrace(); v = inflater.inflate(layout, viewGroup, false); holder.name = (TextView) v.findViewById(R.id.name); holder.screenName = (TextView) v.findViewById(R.id.screen_name); holder.background = (LinearLayout) v.findViewById(R.id.background); holder.picture = (ImageView) v.findViewById(R.id.profile_pic); // holder.divider = v.findViewById(R.id.my_divider); } } else { v = inflater.inflate(layout, viewGroup, false); holder.name = (TextView) v.findViewById(R.id.name); holder.screenName = (TextView) v.findViewById(R.id.screen_name); holder.background = (LinearLayout) v.findViewById(R.id.background); holder.picture = (ImageView) v.findViewById(R.id.profile_pic); // holder.divider = v.findViewById(R.id.my_divider); } // sets up the font sizes holder.name.setTextSize(settings.textSize + 4); holder.screenName.setTextSize(settings.textSize); v.setTag(holder); return v; }