How to Install APK to Android Device via ADB in 6 simple steps

1 1 1 1 1 How to Install APK to Android Device via ADB in 6 simple steps5.00Rating 3.00 (2 Votes)

1. Download and install android platform tools: https://developer.android.com/studio/releases/platform-tools.html

2. Open command line and navigate to the folder where ADB is located, eg. cd /D d:\Android\sdk\platform-tools\

3. Type adb devices and press ENTER.

Read more: How to Install APK to Android Device via ADB in 6 simple steps

Android WebView transparent background for Android 2.3 and 4.x

1 1 1 1 1 Android WebView transparent background for Android 2.3 and 4.x5.00Rating 2.45 (11 Votes)

Many people face an issue with Android's WebView and transparent background. The problem is that if you need to make transparent background for the WebView, it is not easy to do at the first sight. If you try to use property android:background="@android:color/transparent", you will discover that it just don't work as expected. The background is still opaque. Using background color set explicitly as #ff000000 constant sometimes work and sometimes not. 

Read more: Android WebView transparent background for Android 2.3 and 4.x

How to fix android warning: Exported activity does not require permission

1 1 1 1 1 How to fix android warning: Exported activity does not require permission5.00Rating 3.00 (2 Votes)

Go to your project and open Android Manifest file. Lets assume that your manifest file contains an activity that has the details as follows

<activity 
  android:name=".MainActivity">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <data android:scheme="http" android:host="example.com" />
    </intent-filter>
</activity>

Add the following lines as shown below.

<activity
android:name=".MainActivity"
android:exported="false">
<intent-filter>

         <action android:name="android.intent.action.MAIN" />
         <data android:scheme="http" android:host="example.com" />

    </intent-filter>
</activity>

Wonder why we did this? Well… It means that other (arbitrary) applications the user has on his phone can bind to your Service and call whatever method they please that is exposed through your AIDL interface.

Source: http://syedasaraahmed.wordpress.com/2012/09/27/android-warning-exported-activity-does-not-require-permission/

Save settings on application close and restore settings on startup

1 1 1 1 1 Save settings on application close and restore settings on startup5.00Rating 3.00 (2 Votes)

In order to restore preferences upon application startup, you can use Android SharedPreferences class.

In onCreate metod call:

SharedPreferences sharedPref = getSharedPreferences("myprefs", 0);

// restore integer value, 1 - default

integer_value = sharedPref.getInt("integer_value", 1);

//same for the string value
string_value = sharedPref.getString("string_value", "this is a default value";

And in order to save values on application exit, write in onStop method:

SharedPreferences sharedPref= getSharedPreferences("myprefs", 0);
SharedPreferences.Editor editor= sharedPref.edit();

editor.putString("string_value", string_value);
editor.putInt("integer_value", integer_value);
editor.commit();

You can actually save other types of data also.

Also see these articles:
1. http://samir-mangroliya.blogspot.in/p/android-shared-preferences.html
2. http://developer.android.com/guide/topics/data/data-storage.html

Thursday the 23rd.