Tag : android

Is it possible to create a Android activity without UI? Yes it is. Android provides a theme for this requirement. Add the following line to your AndroidManifest.xml and call finish() at the end of the Activity’s onCreate() method. android:theme=”@android:style/Theme.NoDisplay” Theme_NoDisplay public static final class android.R.style – Added in API level 3 int Theme_NoDisplay Default theme ..

Read more

With API Level 14 – Android 4.0, there is a Method in Application which is called onTrimMemory. The onTrimMemory is executed by the system with different levels ( TRIM_MEMORY_COMPLETE, TRIM_MEMORY_MODERATE, TRIM_MEMORY_BACKGROUND, TRIM_MEMORY_UI_HIDDEN, TRIM_MEMORY_RUNNING_CRITICAL, TRIM_MEMORY_RUNNING_LOW, or TRIM_MEMORY_RUNNING_MODERATE). The interesting level is “TRIM_MEMORY_UI_HIDDEN”. This level can be used to know that the app is going to background. ..

Read more

Not a snippet, but a needed Information when using Microsoft Android Calc How to Format cells in Excel for Android. (Sceenshot made on a german device) Some more informations are available in the video at https://support.office.com/en-us/article/Video-Getting-started-with-Excel-for-Android-tablet-c5d5c135-0bc1-4aea-9b54-95a518dd0c11. Excel for Android is very similar to Microsoft Excel for Windows. But some differences can confuse sometimes. The short ..

Read more

To execute a shell command from your android app you can grab the standard input of the su process just launched by Runtime.getRuntime().exec(“su”) and write down the command there, otherwise you are running the commands with the current UID. With the following code you can excute the screenrecord command to grab your screen to a ..

Read more

If you want to develop an Android app to turn on/off GPS you can use the following code snippets. // turn on gps public void turnGPSOn() { Intent intent = new Intent(“android.location.GPS_ENABLED_CHANGE”); intent.putExtra(“enabled”, true); this.ctx.sendBroadcast(intent); String provider = Settings.Secure.getString(ctx.getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED); if(!provider.contains(“gps”)){ //if gps is disabled final Intent poke = new Intent(); poke.setClassName(“com.android.settings”, “com.android.settings.widget.SettingsAppWidgetProvider”); poke.addCategory(Intent.CATEGORY_ALTERNATIVE); poke.setData(Uri.parse(“3”)); ..

Read more

Mobile devices have virtual keyboards. There is only limited space on the display to show the keyboard, so it will be helpful to the user to see only the needed keys. Using the right input type will dramatically improve the mobile experience. There are many different input types available for html pages. Here are my ..

Read more

There is a simple solution, to get the name of the current method in Java. It uses the stack trace to get the name of the mehod. It works with different virtual machines like oracle, dalvik (Android), Open JDK, etc. String name = Thread.currentThread().getStackTrace()[1].getMethodName(); But don’t use this in time-critical code, because working with the ..

Read more

This is a simple Android background Service Template. You can use it to run updates in the background without blocking the UI. To start and stop the service use the following lines in your activity: // starting the service Intent intent = new Intent(this, UpdateService .class); startService(intent); // stopping the service Intent intent = new ..

Read more