private ComponentName getIntentService(Context context) { try { PackageInfo info = context .getPackageManager() .getPackageInfo(context.getPackageName(), PackageManager.GET_SERVICES); if (info.services != null) { try { for (ServiceInfo service : info.services) { Class<?> serviceClass = Class.forName(service.name); if (AbstractGcmIntentService.class.isAssignableFrom(serviceClass)) { Log.d( "GCMBroadcastReceiver", "found the IntentService. package=" + service.packageName + " class=" + service.name); return new ComponentName(service.packageName, service.name); } } } catch (Exception ignore) { } } } catch (Exception ignore) { } Log.w( "GCMBroadcastReceiver", "cannot find the IntentService in AndroidManifest.xml try to use defalut. package=" + context.getPackageName() + " class=" + GcmIntentService.class.getName()); return new ComponentName(context.getPackageName(), GcmIntentService.class.getName()); }
@Override public RemoteViews getViewAt(int position) { RemoteViews row; Match match = data.get(position); if (match.getTitle() != null) { row = new RemoteViews(context.getPackageName(), R.layout.widget_scores_section); row.setTextViewText(R.id.title, match.getTitle()); } else { row = new RemoteViews(context.getPackageName(), R.layout.widget_scores_list_item); row.setTextViewText(R.id.home_name, match.getHome()); row.setTextViewText(R.id.away_name, match.getAway()); row.setImageViewResource(R.id.home_crest, match.getHomeCrest()); row.setImageViewResource(R.id.away_crest, match.getAwayCrest()); row.setTextViewText(R.id.data_textview, match.getMacthTime()); row.setTextViewText(R.id.score_textview, match.getScore()); } Intent fillInIntent = new Intent(); fillInIntent.putExtra("ROW_NUMBER", position); row.setOnClickFillInIntent(R.id.row, fillInIntent); ; return row; }
public zzps zza( Context context, Looper looper, zzf zzf1, PlacesOptions placesoptions, com.google.android.gms.common.api.GoogleApiClient.ConnectionCallbacks connectioncallbacks, com.google.android.gms.common.api.GoogleApiClient.OnConnectionFailedListener onconnectionfailedlistener) { String s; String s1; if (zzaor != null) { s = zzaor; } else { s = context.getPackageName(); } if (zzaos != null) { s1 = zzaos; } else { s1 = context.getPackageName(); } if (placesoptions == null) { placesoptions = (new com.google.android.gms.location.places.PlacesOptions.Builder()).build(); } return new zzps( context, looper, zzf1, connectioncallbacks, onconnectionfailedlistener, s, s1, placesoptions); }
/** * 注册PUSH服务 * * @param schoolid * @param schoolkey * @throws RemoteException */ public static void Register(String schoolid, String schoolkey) throws RemoteException { String packageName = mContext.getPackageName(); PushRegItem regItem = new PushRegItem(); regItem.packageName = packageName; regItem.SchoolID = schoolid; regItem.SchoolKey = schoolkey; regItem.appver = ""; PackageManager packageManager = mContext.getPackageManager(); try { PackageInfo packInfo = packageManager.getPackageInfo(mContext.getPackageName(), 0); regItem.appver = packInfo.versionName; } catch (NameNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } mDrPalmPushService.RegAppPush( regItem, new IDrPalmPushCallback.Stub() { @Override public void onError(String err) throws RemoteException { // callback.onError(err); } @Override public void onSuccess() throws RemoteException { // callback.onSuccess(); } }); }
public static String printKeyHash(Context context) { PackageInfo packageInfo; String key = null; try { // getting application package name, as defined in manifest String packageName = context.getPackageName(); // Retriving package info packageInfo = context.getPackageManager().getPackageInfo(packageName, PackageManager.GET_SIGNATURES); Debug.e("Package Name=" + context.getPackageName()); for (Signature signature : packageInfo.signatures) { MessageDigest md = MessageDigest.getInstance("SHA"); md.update(signature.toByteArray()); key = new String(Base64.encode(md.digest(), 0)); // String key = new String(Base64.encodeBytes(md.digest())); Debug.e("Key Hash=" + key); } } catch (PackageManager.NameNotFoundException e1) { Debug.e("Name not found" + e1.toString()); } catch (NoSuchAlgorithmException e) { Debug.e("No such an algorithm" + e.toString()); } catch (Exception e) { Debug.e("Exception" + e.toString()); } return key; }
public static void showPlayingNotification( final Context context, final DownloadServiceImpl downloadService, Handler handler, MusicDirectory.Entry song) { // Set the icon, scrolling text and timestamp final Notification notification = new Notification( R.drawable.stat_notify_playing, song.getTitle(), System.currentTimeMillis()); notification.flags |= Notification.FLAG_NO_CLEAR | Notification.FLAG_ONGOING_EVENT; boolean playing = downloadService.getPlayerState() == PlayerState.STARTED; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { RemoteViews expandedContentView = new RemoteViews(context.getPackageName(), R.layout.notification_expanded); setupViews(expandedContentView, context, song, playing); notification.bigContentView = expandedContentView; } RemoteViews smallContentView = new RemoteViews(context.getPackageName(), R.layout.notification); setupViews(smallContentView, context, song, playing); notification.contentView = smallContentView; Intent notificationIntent = new Intent(context, DownloadActivity.class); notification.contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0); NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); manager.notify(notificationID, notification); // Update widget DSubWidgetProvider.getInstance().notifyChange(context, downloadService, true); }
public static void LoadApplication( Context context, ApplicationInfo runtimePackage, String[] apks) { synchronized (lock) { if (!initialized) { System.loadLibrary("monodroid"); Locale locale = Locale.getDefault(); String language = locale.getLanguage() + "-" + locale.getCountry(); String filesDir = context.getFilesDir().getAbsolutePath(); String cacheDir = context.getCacheDir().getAbsolutePath(); String dataDir = getNativeLibraryPath(context); ClassLoader loader = context.getClassLoader(); Runtime.init( language, apks, getNativeLibraryPath(runtimePackage), new String[] { filesDir, cacheDir, dataDir, }, loader, new java.io.File( android.os.Environment.getExternalStorageDirectory(), "Android/data/" + context.getPackageName() + "/files/.__override__") .getAbsolutePath(), MonoPackageManager_Resources.Assemblies, context.getPackageName()); initialized = true; } } }
/** * Static method for copy the database from asset directory to application's data directory */ private static void copyDataBase(Context aContext, String databaseName) throws IOException { // Open your local db as the input stream InputStream myInput = aContext.getAssets().open(databaseName); // Path to the just created empty db String outFileName = getDatabasePath(aContext, databaseName); Log.i( TAG, "Check if create dir : " + DB_PATH_PREFIX + aContext.getPackageName() + DB_PATH_SUFFIX); // if the path doesn't exist first, create it File f = new File(DB_PATH_PREFIX + aContext.getPackageName() + DB_PATH_SUFFIX); if (!f.exists()) f.mkdir(); Log.i(TAG, "Trying to copy local DB to : " + outFileName); // Open the empty db as the output stream OutputStream myOutput = new FileOutputStream(outFileName); // transfer bytes from the inputfile to the outputfile byte[] buffer = new byte[1024]; int length; while ((length = myInput.read(buffer)) > 0) { myOutput.write(buffer, 0, length); } // Close the streams myOutput.flush(); myOutput.close(); myInput.close(); Log.i(TAG, "DB (" + databaseName + ") copied!"); }
@Override protected void onPostExecute(String notificationsJson) { super.onPostExecute(notificationsJson); String packageName = this.getClass().getPackage().getName(); SharedPreferences prefs = _context.getSharedPreferences(packageName, Context.MODE_PRIVATE); String title = prefs.getString(Constants.SETTING_TITLE, ""); String icon = prefs.getString(Constants.SETTING_ICON, ""); int iconId = _context.getResources().getIdentifier(icon, "drawable", _context.getPackageName()); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(_context) .setAutoCancel(true) .setSmallIcon(iconId) .setContentTitle(title) .setContentText("Get yer ya-yas out!"); // TODO PackageManager packageManager = _context.getPackageManager(); Intent resultIntent = packageManager.getLaunchIntentForPackage(_context.getPackageName()); // TODO change if want to go to a specific page in PAR Mobile when notification is clicked PendingIntent resultPendingIntent = PendingIntent.getActivity(_context, 0, resultIntent, PendingIntent.FLAG_UPDATE_CURRENT); notificationBuilder.setContentIntent(resultPendingIntent); NotificationManager notificationManager = (NotificationManager) _context.getSystemService(Context.NOTIFICATION_SERVICE); Notification notification = notificationBuilder.build(); notificationManager.notify(0, notification); }
@Override public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { for (int i = 0; i < appWidgetIds.length; i++) { // Setup the widget, and data source / adapter Intent svcIntent = new Intent(context, DDWidgetService.class); svcIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetIds[i]); svcIntent.setData(Uri.parse(svcIntent.toUri(Intent.URI_INTENT_SCHEME))); RemoteViews widget; SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); if (sp.getString("theme", "Light").equals("Light")) { widget = new RemoteViews(context.getPackageName(), R.layout.widget_layout); } else { widget = new RemoteViews(context.getPackageName(), R.layout.widget_layout_dark); } widget.setRemoteAdapter(R.id.listView, svcIntent); Intent clickIntent = new Intent(context, ClickHandlingActivity.class); PendingIntent clickPI = PendingIntent.getActivity(context, 0, clickIntent, PendingIntent.FLAG_UPDATE_CURRENT); widget.setPendingIntentTemplate(R.id.listView, clickPI); appWidgetManager.updateAppWidget(appWidgetIds[i], widget); } super.onUpdate(context, appWidgetManager, appWidgetIds); }
int queryPurchases(Inventory inv, String itemType) throws JSONException, RemoteException { // Query purchases logDebug("Querying owned items, item type: " + itemType); logDebug("Package name: " + mContext.getPackageName()); boolean verificationFailed = false; String continueToken = null; do { logDebug("Calling getPurchases with continuation token: " + continueToken); Bundle ownedItems = mService.getPurchases(3, mContext.getPackageName(), itemType, continueToken); int response = getResponseCodeFromBundle(ownedItems); logDebug("Owned items response: " + String.valueOf(response)); if (response != BILLING_RESPONSE_RESULT_OK) { logDebug("getPurchases() failed: " + getResponseDesc(response)); return response; } if (!ownedItems.containsKey(RESPONSE_INAPP_ITEM_LIST) || !ownedItems.containsKey(RESPONSE_INAPP_PURCHASE_DATA_LIST) || !ownedItems.containsKey(RESPONSE_INAPP_SIGNATURE_LIST)) { logError("Bundle returned from getPurchases() doesn't contain required fields."); return IABHELPER_BAD_RESPONSE; } ArrayList<String> ownedSkus = ownedItems.getStringArrayList(RESPONSE_INAPP_ITEM_LIST); ArrayList<String> purchaseDataList = ownedItems.getStringArrayList(RESPONSE_INAPP_PURCHASE_DATA_LIST); ArrayList<String> signatureList = ownedItems.getStringArrayList(RESPONSE_INAPP_SIGNATURE_LIST); for (int i = 0; i < purchaseDataList.size(); ++i) { String purchaseData = purchaseDataList.get(i); String signature = signatureList.get(i); String sku = ownedSkus.get(i); if (Security.verifyPurchase(mSignatureBase64, purchaseData, signature)) { logDebug("Sku is owned: " + sku); Purchase purchase = new Purchase(itemType, purchaseData, signature); if (TextUtils.isEmpty(purchase.getToken())) { logWarn("BUG: empty/null token!"); logDebug("Purchase data: " + purchaseData); } // Record ownership and token inv.addPurchase(purchase); } else { logWarn("Purchase signature verification **FAILED**. Not adding item."); logDebug(" Purchase data: " + purchaseData); logDebug(" Signature: " + signature); verificationFailed = true; } } continueToken = ownedItems.getString(INAPP_CONTINUATION_TOKEN); logDebug("Continuation token: " + continueToken); } while (!TextUtils.isEmpty(continueToken)); return verificationFailed ? IABHELPER_VERIFICATION_FAILED : BILLING_RESPONSE_RESULT_OK; }
static void updateAppWidget(Context context, AppWidgetManager appWidgetManager, int appWidgetId) { Log.d(TAG, "updateAppWidget ID:" + appWidgetId); boolean isContentProviderInstalled = isPackageInstalled(CONTENT_PROVIDER_PACKAGE, context); /* Log.d(TAG, "is On This Day installed:"+isContentProviderInstalled); Log.d(TAG, "is ContentProviderInstalled:"+DataFetcher.isProviderInstalled(context)); */ // save current Lang Resources res = context.getResources(); Configuration conf = res.getConfiguration(); String currentLang = conf.locale.getLanguage(); // get settings lang String settingLang = SettingsActivity.loadPrefs(context, appWidgetId); if (settingLang == null || settingLang.isEmpty()) { settingLang = currentLang; } Date currentDate = new Date(); RemoteViews rv; if (!isContentProviderInstalled) { // no content provider rv = new RemoteViews(context.getPackageName(), R.layout.plz_install_widget_layout); // Create an Intent to launch Play Market Intent intent; // TODO check is market:// parsed try { intent = new Intent( Intent.ACTION_VIEW, Uri.parse("market://details?id=" + CONTENT_PROVIDER_PACKAGE)); } catch (android.content.ActivityNotFoundException anfe) { intent = new Intent( Intent.ACTION_VIEW, Uri.parse( "https://play.google.com/store/apps/details?id=" + CONTENT_PROVIDER_PACKAGE)); } PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0); rv.setOnClickPendingIntent(R.id.installView, pendingIntent); } else { rv = new RemoteViews(context.getPackageName(), R.layout.atd_widget_layout); setTitle(rv, context, settingLang, currentDate); // start service for getData and create Views setList(rv, context, settingLang, currentDate, appWidgetId); } // // Do additional processing specific to this app widget... // appWidgetManager.updateAppWidget(appWidgetId, rv); }
@Override public void onReceive(Context context, Intent intent) { // Log.v(TAG, "Receiving: " + intent.getAction()); if (intent.getAction().equals(OppProbe.getStatusAction(probeName))) { OppProbe.Status status = new OppProbe.Status(intent.getExtras()); if (probeName.equals(status.getName())) { Log.i(TAG, "Is a status action for " + probeName); long nonce = intent.getLongExtra(OppProbe.ReservedParamaters.NONCE.name, 0L); Log.i(TAG, "Nonce is " + nonce + "'"); if (!sent && nonce != 0L) { sent = true; expirationTimer.cancel(); try { context.unregisterReceiver(DataResponder.this); } catch (IllegalArgumentException e) { // already removed; } final Intent i = new Intent(OppProbe.getGetAction(probeName)); Log.i(TAG, "Sending intent '" + i.getAction() + "'"); i.setPackage(context.getPackageName()); // Send only to this app for right now i.putExtra(OppProbe.ReservedParamaters.PACKAGE.name, context.getPackageName()); if (requestId != null && !"".equals(requestId)) { i.putExtra(OppProbe.ReservedParamaters.REQUEST_ID.name, requestId); } i.putExtra(OppProbe.ReservedParamaters.REQUESTS.name, requests); i.putExtra(OppProbe.ReservedParamaters.NONCE.name, nonce); context.sendBroadcast(i); } } } }
@Override public void onReceive(Context context, Intent intent) { super.onReceive(context, intent); if (CLOCK_WIDGET_UPDATE.equals(intent.getAction())) { Bundle extras = intent.getExtras(); if (extras != null) { AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context); ComponentName thisAppWidget = new ComponentName(context.getPackageName(), VerboseClockWidget.class.getName()); int[] appWidgetIds = appWidgetManager.getAppWidgetIds(thisAppWidget); onUpdate(context, appWidgetManager, appWidgetIds); } } else { Bundle extras = intent.getExtras(); if (extras != null) { AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context); ComponentName thisAppWidget = new ComponentName(context.getPackageName(), VerboseClockWidget.class.getName()); int[] appWidgetIds = appWidgetManager.getAppWidgetIds(thisAppWidget); onUpdate(context, appWidgetManager, appWidgetIds); } } }
protected static void showTrayNotification( Context context, String message, String data, String badgeNumber, String userKey) { // get a reference to the service String ns = Context.NOTIFICATION_SERVICE; final NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(ns); // parse the message for test mode String testModeApp = null; if (message.indexOf('[') == 0) { testModeApp = message.substring(1, message.indexOf(']')); message = message.substring(message.indexOf(']') + 1).trim(); } if (testModeApp == null && AppMobiActivity.sharedActivity != null) { // check if we are running in TestAnywhere mode if (AppMobiActivity.sharedActivity.configData != null && context.getPackageName().endsWith(AppMobiActivity.sharedActivity.configData.appName)) { testModeApp = AppMobiActivity.sharedActivity.configData.appName; } } // create the notification instance int icon = R.drawable.icon; CharSequence tickerText = message; long when = System.currentTimeMillis(); final Notification notification = new Notification(icon, tickerText, when); // initialize latest event info CharSequence contentTitle = context.getString(R.string.app_name) + ": " + badgeNumber + " unread messages."; CharSequence contentText = message; Intent notificationIntent = null; // if(MainActivity.sharedActivity!=null) { // notificationIntent = new Intent(MainActivity.sharedActivity, MainActivity.class); // } else { try { // notificationIntent = new Intent(context, getClassForPendingIntent(context)); notificationIntent = new Intent(context, Class.forName(context.getPackageName() + ".MainActivity")); } catch (ClassNotFoundException e) { e.printStackTrace(); if (Debug.isDebuggerConnected()) Log.e( "[appMobi]", "getClassForPendingIntent returned null, unable to show tray notification"); } notificationIntent.setAction(Intent.ACTION_MAIN); notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // } // add extra so we can know we were started from tray - set value to test mode app, if any notificationIntent.putExtra(FROM_NOTIFICATION, testModeApp != null ? testModeApp : ""); notificationIntent.putExtra(C2DM_USERKEY_EXTRA, userKey); PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0); notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent); // make notification non-cancellable notification.flags = notification.flags | Notification.FLAG_NO_CLEAR; // show in status bar mNotificationManager.notify(PUSH_NOTIFICATION_ID, notification); // this would remove notification from status bar // mNotificationManager.cancel(BUSY_INDICATOR); }
public void requestStatus(boolean includeNonce) { final Intent i = new Intent(OppProbe.getPollAction(probeName)); Log.i(TAG, "Sending intent '" + i.getAction() + "'"); i.setPackage(context.getPackageName()); i.putExtra(OppProbe.ReservedParamaters.PACKAGE.name, context.getPackageName()); i.putExtra(OppProbe.ReservedParamaters.NONCE.name, includeNonce); context.sendBroadcast(i); }
public static void hideIcon(Context context) { context .getPackageManager() .setComponentEnabledSetting( new ComponentName(context.getPackageName(), context.getPackageName() + ".MainActivity"), PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); }
public PolicyManager(Context context) { // TODO Auto-generated constructor stub this.mContext = context; mDPM = (DevicePolicyManager) mContext.getSystemService(Context.DEVICE_POLICY_SERVICE); adminComponent = new ComponentName( mContext.getPackageName(), mContext.getPackageName() + ".SampleDeviceAdminReceiver"); }
public static boolean iconEnabled(Context context) { return context .getPackageManager() .getComponentEnabledSetting( new ComponentName( context.getPackageName(), context.getPackageName() + ".MainActivity")) == PackageManager.COMPONENT_ENABLED_STATE_ENABLED; }
public static Uri getResourceUri(Context packageContext, int res) { try { Resources resources = packageContext.getResources(); return getResourceUri(resources, packageContext.getPackageName(), res); } catch (Resources.NotFoundException e) { Log.e(TAG, "Resource not found: " + res + " in " + packageContext.getPackageName()); return null; } }
public void setData(Acc acc) { int acc_id = acc.getAcc_id(); int acc_star = acc.getAcc_star(); int item = getResources().getIdentifier("acc" + acc_id, "drawable", context.getPackageName()); int star = getResources().getIdentifier("star_" + acc_star, "drawable", context.getPackageName()); img_item.setImageResource(item); img_star.setImageResource(star); txt_name.setText(acc.getAcc_name()); }
public String getAppName() { PackageManager pm = context.getPackageManager(); String appName; try { ApplicationInfo ai = pm.getApplicationInfo(context.getPackageName(), 0); appName = pm.getApplicationLabel(ai).toString(); } catch (NameNotFoundException e) { appName = context.getPackageName(); } return appName; }
@Override public void onReceive(Context context, Intent intent) { final String action = intent.getAction(); final boolean enabled = intent.getBooleanExtra(LocationManager.EXTRA_GPS_ENABLED, false); boolean visible; int iconId, textResId; if (action.equals(LocationManager.GPS_FIX_CHANGE_ACTION) && enabled) { // GPS is getting fixes iconId = com.android.internal.R.drawable.stat_sys_gps_on; textResId = R.string.gps_notification_found_text; visible = true; } else if (action.equals(LocationManager.GPS_ENABLED_CHANGE_ACTION) && !enabled) { // GPS is off visible = false; iconId = textResId = 0; } else { // GPS is on, but not receiving fixes iconId = R.drawable.stat_sys_gps_acquiring_anim; textResId = R.string.gps_notification_searching_text; visible = true; } try { if (visible) { Intent gpsIntent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); gpsIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, gpsIntent, 0); Notification n = new Notification.Builder(mContext) .setSmallIcon(iconId) .setContentTitle(mContext.getText(textResId)) .setOngoing(true) .setContentIntent(pendingIntent) .getNotification(); // Notification.Builder will helpfully fill these out for you no matter what you do n.tickerView = null; n.tickerText = null; n.priority = Notification.PRIORITY_HIGH; int[] idOut = new int[1]; mNotificationService.enqueueNotificationWithTag( mContext.getPackageName(), null, GPS_NOTIFICATION_ID, n, idOut); } else { mNotificationService.cancelNotification(mContext.getPackageName(), GPS_NOTIFICATION_ID); } } catch (android.os.RemoteException ex) { // well, it was worth a shot } }
private void updatePausePlay() { if (mRoot == null || mPauseButton == null) return; if (mPlayer.isPlaying()) mPauseButton.setImageResource( getResources() .getIdentifier("mediacontroller_pause", "drawable", mContext.getPackageName())); else mPauseButton.setImageResource( getResources() .getIdentifier("mediacontroller_play", "drawable", mContext.getPackageName())); }
public static int getClientVersion(Context context) { try { Log.d( TAG, context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionCode + ""); return context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionCode; } catch (NameNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } return -1; }
/** * Get package name as defined in the manifest. * * @return the package name. */ public static String getPkgName() { String pkgName = TAG; Context context = sInstance.getApplicationContext(); try { PackageInfo pInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0); pkgName = context.getString(pInfo.applicationInfo.labelRes); } catch (PackageManager.NameNotFoundException e) { Log.e(TAG, "Couldn't find package named " + context.getPackageName(), e); } return pkgName; }
public l(Context context, AudioManager audioManager, View view, k kVar) { this.a = context; this.b = audioManager; this.c = view; this.d = kVar; this.e = context.getPackageName() + ":transport:" + System.identityHashCode(this); this.g = new Intent(this.e); this.g.setPackage(context.getPackageName()); this.f = new IntentFilter(); this.f.addAction(this.e); this.c.getViewTreeObserver().addOnWindowAttachListener(this.h); this.c.getViewTreeObserver().addOnWindowFocusChangeListener(this.i); }
/** * Get the package version as defined in the manifest. * * @return the package version. */ public static String getPkgVersion() { String pkgVersion = "?"; Context context = sInstance.getApplicationContext(); try { PackageInfo pInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0); pkgVersion = pInfo.versionName; } catch (PackageManager.NameNotFoundException e) { Log.e(TAG, "Couldn't find package named " + context.getPackageName(), e); } return pkgVersion; }
static void setResIDS(Context app) { RES_IDS[0] = app.getResources() .getIdentifier("gamehelper_unknown_error", "string", app.getPackageName()); RES_IDS[1] = app.getResources() .getIdentifier("gamehelper_sign_in_failed", "string", app.getPackageName()); RES_IDS[2] = app.getResources() .getIdentifier("gamehelper_app_misconfigured", "string", app.getPackageName()); RES_IDS[3] = app.getResources() .getIdentifier("gamehelper_license_failed", "string", app.getPackageName()); }
private QuestionnaireManager(Context ctx) { Log.d("PCL", "QuestionnaireManager created"); context = ctx; dbHelper = new QuestionnaireDatabase(ctx); runCacherIntent = new Intent(ctx.getPackageName() + QUESTIONNAIRE_CACHER_INTENT_ACTION); runCacherPendingIntent = PendingIntent.getBroadcast(context, 0, runCacherIntent, 0); runCacherBroadcastReceiver = new RunCacherBroadcastReceiver(); IntentFilter filter = new IntentFilter(); filter.addAction(ctx.getPackageName() + QUESTIONNAIRE_CACHER_INTENT_ACTION); context.registerReceiver(runCacherBroadcastReceiver, filter); }