Scriptico

Issue with Facebook Key Hashes for the Android Application

During the last three months I have been working as a developer for a consulting android project. It is actually my first commercial experience (I do not count written demo examples at my previous work) and I found it extremely interesting, though a quite confusing at some moments.

The following article describes an observed problem with the facebook key hashes for the android application. To describe the problem and its solution, let’s define a simple use case.
Read the rest of this entry »

How to restart an application in android programmatically

The following code snippet shows how to restart an android application after the specified delay programmatically:

public void restart(int delay) {
	PendingIntent intent = PendingIntent.getActivity(this.getBaseContext(), 0, new Intent(getIntent()), getIntent().getFlags());
	AlarmManager manager = (AlarmManager) this.getSystemService(Context.ALARM_SERVICE);
	manager.set(AlarmManager.RTC, System.currentTimeMillis() + delay, intent);
	System.exit(2);
}

Related API:
PendingIntent
AlarmManager

How to minimize an application in android programmatically

The following code snippet shows how to minimize the current application in android programmatically:

Intent main = new Intent(Intent.ACTION_MAIN);
main.addCategory(Intent.CATEGORY_HOME);
main.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(main);

Related API:
Activity