android Programming Glossary: context.getpackagename
Using DiskLruCache in android 4.0 does not provide for openCache method http://stackoverflow.com/questions/10185898/using-disklrucache-in-android-4-0-does-not-provide-for-opencache-method cache dir ourselves final String cacheDir Android data context.getPackageName cache return new File Environment.getExternalStorageDirectory..
How to send parameters from a notification-click to an activity? http://stackoverflow.com/questions/1198558/how-to-send-parameters-from-a-notification-click-to-an-activity final RemoteViews contentView new RemoteViews context.getPackageName R.layout.custom_notification_layout contentView.setImageViewResource..
Launching activity from widget http://stackoverflow.com/questions/1937236/launching-activity-from-widget context 0 intent 0 RemoteViews views new RemoteViews context.getPackageName R.layout.widget views.setOnClickPendingIntent R.id.button pendingIntent.. for the App Widget RemoteViews views new RemoteViews context.getPackageName R.layout.togglelayout attach the click listener for the service.. componenet for self ComponentName comp new ComponentName context.getPackageName ToggleWidget.class.getName tell the manager to update all instances..
Processing more than one button click at Android Widget http://stackoverflow.com/questions/2471875/processing-more-than-one-button-click-at-android-widget Context context RemoteViews updateViews new RemoteViews context.getPackageName R.layout.main_layout Intent i new Intent this ExampleProvider.class.. int appWidgetIds RemoteViews remoteViews new RemoteViews context.getPackageName R.layout.main_layout Intent active new Intent context ExampleProvider.class..
Clickable widgets in android http://stackoverflow.com/questions/2748590/clickable-widgets-in-android listener to the button RemoteViews views new RemoteViews context.getPackageName R.layout.appwidget_provider_layout views.setOnClickPendingIntent..
Intent to launch the clock application on android http://stackoverflow.com/questions/3590955/intent-to-launch-the-clock-application-on-android if VERSION.SDK.equals 7 RemoteViews views new RemoteViews context.getPackageName R.layout.widget Intent AlarmClockIntent new Intent Intent.ACTION_MAIN.. if VERSION.SDK.equals 8 RemoteViews views new RemoteViews context.getPackageName R.layout.widget Intent AlarmClockIntent new Intent Intent.ACTION_MAIN.. with 1.5 and 1.6 else RemoteViews views new RemoteViews context.getPackageName R.layout.widget Intent AlarmClockIntent new Intent Intent.ACTION_MAIN..
Getting View's coordinates relative to the root layout http://stackoverflow.com/questions/3619693/getting-views-coordinates-relative-to-the-root-layout
How to use a custom typeface in a widget? http://stackoverflow.com/questions/4318572/how-to-use-a-custom-typeface-in-a-widget appWidgetId appWidgetIds RemoteViews top new RemoteViews context.getPackageName R.layout.main Intent clickintent new Intent android.tristan.widget.digiclock.CLICK.. appWidgetIds RemoteViews bottom new RemoteViews context.getPackageName R.layout.main Intent clickintent new Intent android.tristan.widget.digiclock.CLICK_2..
How to get the build/version number of your android application? http://stackoverflow.com/questions/4616095/how-to-get-the-build-version-number-of-your-android-application
Android - how to get app signature? http://stackoverflow.com/questions/5578871/android-how-to-get-app-signature Signature sigs context.getPackageManager .getPackageInfo context.getPackageName PackageManager.GET_SIGNATURES .signatures for Signature sig..
Difference between getDefaultSharedPreferences and getSharedPreferences http://stackoverflow.com/questions/5946135/difference-between-getdefaultsharedpreferences-and-getsharedpreferences getDefaultSharedPreferencesName Context context return context.getPackageName _preferences private static int getDefaultSharedPreferencesMode..
check android application is in foreground or not? http://stackoverflow.com/questions/8489993/check-android-application-is-in-foreground-or-not if appProcesses null return false final String packageName context.getPackageName for RunningAppProcessInfo appProcess appProcesses if appProcess.importance..
How to use an existing database with an Android application [duplicate] http://stackoverflow.com/questions/9109438/how-to-use-an-existing-database-with-an-android-application .dataDir databases else DB_PATH data data context.getPackageName databases this.mContext context public void createDataBase throws.. Thanks to JDx For Jellybean 4.2 change DB_PATH data data context.getPackageName databases to DB_PATH context.getApplicationInfo .dataDir databases..
Using DiskLruCache in android 4.0 does not provide for openCache method http://stackoverflow.com/questions/10185898/using-disklrucache-in-android-4-0-does-not-provide-for-opencache-method Before Froyo we need to construct the external cache dir ourselves final String cacheDir Android data context.getPackageName cache return new File Environment.getExternalStorageDirectory .getPath cacheDir public static boolean hasExternalCacheDir..
How to send parameters from a notification-click to an activity? http://stackoverflow.com/questions/1198558/how-to-send-parameters-from-a-notification-click-to-an-activity new Notification R.drawable.icon tickerText System.currentTimeMillis final RemoteViews contentView new RemoteViews context.getPackageName R.layout.custom_notification_layout contentView.setImageViewResource R.id.image R.drawable.icon contentView.setTextViewText..
Launching activity from widget http://stackoverflow.com/questions/1937236/launching-activity-from-widget PendingIntent pendingIntent PendingIntent.getActivity context 0 intent 0 RemoteViews views new RemoteViews context.getPackageName R.layout.widget views.setOnClickPendingIntent R.id.button pendingIntent appWidgetManager.updateAppWidget appWidgetId views.. context 0 i 0 intent to start service Get the layout for the App Widget RemoteViews views new RemoteViews context.getPackageName R.layout.togglelayout attach the click listener for the service start command intent views.setOnClickPendingIntent R.id.toggleButton.. R.id.toggleButton myPI define the componenet for self ComponentName comp new ComponentName context.getPackageName ToggleWidget.class.getName tell the manager to update all instances of the toggle widget with the click listener mgr.updateAppWidget..
Processing more than one button click at Android Widget http://stackoverflow.com/questions/2471875/processing-more-than-one-button-click-at-android-widget me buildUpdate this private RemoteViews buildUpdate Context context RemoteViews updateViews new RemoteViews context.getPackageName R.layout.main_layout Intent i new Intent this ExampleProvider.class PendingIntent pi PendingIntent.getBroadcast context.. onUpdate Context context AppWidgetManager appWidgetManager int appWidgetIds RemoteViews remoteViews new RemoteViews context.getPackageName R.layout.main_layout Intent active new Intent context ExampleProvider.class active.setAction ACTION_WIDGET_REFRESH PendingIntent..
Clickable widgets in android http://stackoverflow.com/questions/2748590/clickable-widgets-in-android 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.appwidget_provider_layout views.setOnClickPendingIntent R.id.button pendingIntent Tell the AppWidgetManager to..
Intent to launch the clock application on android http://stackoverflow.com/questions/3590955/intent-to-launch-the-clock-application-on-android on the phone. this is the code this worked on my nexus 2.1 if VERSION.SDK.equals 7 RemoteViews views new RemoteViews context.getPackageName R.layout.widget Intent AlarmClockIntent new Intent Intent.ACTION_MAIN .addCategory Intent.CATEGORY_LAUNCHER .setComponent.. views this worked on my nexus froyo2.2 else if VERSION.SDK.equals 8 RemoteViews views new RemoteViews context.getPackageName R.layout.widget Intent AlarmClockIntent new Intent Intent.ACTION_MAIN .addCategory Intent.CATEGORY_LAUNCHER .setComponent.. views this worked on my htc magic with 1.5 and 1.6 else RemoteViews views new RemoteViews context.getPackageName R.layout.widget Intent AlarmClockIntent new Intent Intent.ACTION_MAIN .addCategory Intent.CATEGORY_LAUNCHER .setComponent..
Getting View's coordinates relative to the root layout http://stackoverflow.com/questions/3619693/getting-views-coordinates-relative-to-the-root-layout
How to use a custom typeface in a widget? http://stackoverflow.com/questions/4318572/how-to-use-a-custom-typeface-in-a-widget final int Bottom appWidgetIds.length for int i 0 i Top i int appWidgetId appWidgetIds RemoteViews top new RemoteViews context.getPackageName R.layout.main Intent clickintent new Intent android.tristan.widget.digiclock.CLICK PendingIntent pendingIntentClick PendingIntent.getBroadcast.. appWidgetId top for int i 0 i Bottom i int appWidgetId appWidgetIds RemoteViews bottom new RemoteViews context.getPackageName R.layout.main Intent clickintent new Intent android.tristan.widget.digiclock.CLICK_2 PendingIntent pendingIntentClick PendingIntent.getBroadcast..
How to get the build/version number of your android application? http://stackoverflow.com/questions/4616095/how-to-get-the-build-version-number-of-your-android-application
Android - how to get app signature? http://stackoverflow.com/questions/5578871/android-how-to-get-app-signature reference android content pm PackageManager.html Signature sigs context.getPackageManager .getPackageInfo context.getPackageName PackageManager.GET_SIGNATURES .signatures for Signature sig sigs Trace.i MyApp Signature hashcode sig.hashCode I've used..
Difference between getDefaultSharedPreferences and getSharedPreferences http://stackoverflow.com/questions/5946135/difference-between-getdefaultsharedpreferences-and-getsharedpreferences context getDefaultSharedPreferencesMode private static String getDefaultSharedPreferencesName Context context return context.getPackageName _preferences private static int getDefaultSharedPreferencesMode return Context.MODE_PRIVATE share improve this answer..
check android application is in foreground or not? http://stackoverflow.com/questions/8489993/check-android-application-is-in-foreground-or-not appProcesses activityManager.getRunningAppProcesses if appProcesses null return false final String packageName context.getPackageName for RunningAppProcessInfo appProcess appProcesses if appProcess.importance RunningAppProcessInfo.IMPORTANCE_FOREGROUND appProcess.processName.equals..
How to use an existing database with an Android application [duplicate] http://stackoverflow.com/questions/9109438/how-to-use-an-existing-database-with-an-android-application if android.os.Build.VERSION.SDK_INT 17 DB_PATH context.getApplicationInfo .dataDir databases else DB_PATH data data context.getPackageName databases this.mContext context public void createDataBase throws IOException If database not exists copy it from the assets.. Cursor testdata mDbHelper.getTestData mDbHelper.close EDIT Thanks to JDx For Jellybean 4.2 change DB_PATH data data context.getPackageName databases to DB_PATH context.getApplicationInfo .dataDir databases in the DataHelper class this code will work on JB 4.2..
|