Localization of Android Apps

If you want to add another language for your app do the following

  • Create a new folder e.g. app/src/main/res/values-de
  • Add strings.xml into this folder
  • Translate the content

The cool thing about translation in android is that you can do it incrementally: when there is no translation for a string resource in a locale Android will automagically use the value from /res/values/strings.xml

Generating SHA-1 for Google API

When you want to interface with any Google API e.g. YouTube from within your Android App, you need to register your app in the developer console.

You have to provide a SHA-1 key which can be generated as following:

Command line

$ chmod u+x gradlew
$ ./gradlew signingReport

Passing data between AndroidActivities

Sending data

private void openVideoActivity(String video) {
    Intent newActivity = new Intent(this, PlayerActivity.class);
    newActivity.putExtra("videoId", video);

Retrieving data

final String videoID = getIntent().getExtras().getString("videoID");

In Kotlin it looks like this:

val intent = Intent(this, NewActivity::class.java).apply {
    putExtra("EXTRA_MESSAGE", "Test 123")


val message = intent.getStringExtra("EXTRA_MESSAGE")

Features and Permissions in Android

Features and Permissions

A permission is something an app is allowed to do 🙂

E.g. using the camera, reading location or accessing your contacts.

<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" android:required="true" />

Internet Access

If your app uses e.g. web-APIs you need internet access. This can be achieved by adding android.permission.INTERNET to your manifest. In this case you need the uses-permission tag.

<manifest package="de.creatronix.sample_app"
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>


Allows applications to open network sockets.


Allows applications to access information about networks.


When You have resources which do not use TLS (https but just http) you have to add



Permissions in Services

Checking Permission

import android.content.pm.PackageManager;
int uid = getCallingUid(); 
int pid = getCallingPid(); 
Log.d(LOGTAG, "Message from PID " + pid + " UID " + uid);
int perm = mContext.checkPermission("de.creatronix.my_service.MY_PERM", pid, uid); 
if (perm == PackageManager.PERMISSION_GRANTED) 
    Log.d(LOGTAG, "Granted"); 
    Log.d(LOGTAG, "Denied");

Enforcing Permissions

mContext.enforceCallingPermission("de.creatronix.my_service.MY_PERM", "echoString permission not granted"); 

More about permissions: