Intel® Hardware Accelerated Execution Manager and OS X Mavericks

As you know, Android emulators are very very very slow :/  So we are using Intel HAXM for speeding up our emulator. But there is a problem with the new OS X Mavericks system. It freezes when you just install HAXM from SDK manager and start your first emulator. Also If you search a little bit you’ll probably come across to a solution that Intel released. It’s a HotFix for OS X Mavericks. After installing this fix, you’ll be able to use your emulator at sonic speed :)

Here is the link for HotFix…: http://software.intel.com/en-us/android/articles/intel-hardware-accelerated-execution-manager-end-user-license-agreement-macos-hotfix

After installing your HAXM from SDK Manager, just download this fix and install it. It will solve the problem.

Don’t use Java JDK 8 for Android development on OS X

I’ve recently switch to OS X Mavericks. But there was no Java installed by default on this system due to security policy of the Apple. So I decided to install Java JDK from Oracle’s website. I’ve installed the latest version of the JDK which is JDK 1.8.0. So I downloaded and installed it. Then I started my Eclipse ADT Bundle. It showed me an error about the JRE. And It was basically saying “You need to install Java JRE 6 to run Eclipse”. So I’ve installed default Apple Java Runtime Environment 6 from this link:  http://support.apple.com/kb/dl1572

This installation solved my problem at first. Eclipse opened properly and I downloaded all of the necessary android sdk files from the SDK Manager. Then I’ve encountered an error and it was saying;

“posix_spawn is not a supported process launch mechanism on this platform”

At first I couldn’t find any solution for that problem on any website. Even posted on Stackoverflow. Then I also installed Java JDK 1.7.0 on my system. And decided to remove JDK 8 from my system and go with JDK7. This method worked fine for Eclipse and problems solved suddenly.

So don’t use JDK 8 for Android development on Eclipse!

What if you forgot your Android keystore password?

Android keystore is so important for updating your application on the market. You musn’t forget your keystore password in order to sign your apk. Because forgeting your keystore password also means loosing your application. You never want it.

Let assume you forgot your keystore password. There is a method that you can restore your password. But there is no guarantee that you will get your password. This method is called  “smart word list attack”. With this method you’ll need a jar packacge which is called AndroidKeystoreBrute_v1.03.jar. Also with this jar you’ll need a txt file for the possible word list that your password could contain. This small program simply checks all the iterations in this txt file. So the list in this file must be related with your password. So you should remember maybe a little bit of your password. At least some letters :)

For example, your password is “bl13ue0bird”. So in order to find your password your wordlist text file should contain some of the words or letter of this password.

blue
bird

How to implement:
First download this jar file from this link -> https://code.google.com/p/android-keystore-password-recover/downloads/list

Next copy this jar file to a directory such as \home directory. In this directory create your own “wordlist” text file. Then also copy your keystore file into this directory. Now open your terminal/console and enter to your directory which your jar file exist.

Now put this line into your console, change “yourkeystore” to yours, change “wordlist” to your text file and press enter.

java -jar AndroidKeystoreBrute_v1.03.jar -m 3 -k “yourkeystore” -d “wordlist”

If you lucky enough you’ll get keystore password. But remember it could take long time to detect your password.

You can find more methods like brute force attack at this link
https://code.google.com/p/android-keystore-password-recover/wiki/HowTo

 

How to easily make custom push notifications using Parse?

Sending push notificaitons to your users is very useful. And it is very simple with backend services like Parse.

This tutorial can be helpful if you are familiar with the Parse. Otherwise you should at least finish simple push notification tutorial at Parse Tutorials.

If you’ve already finished this tutorial you might noticed that this implication is just sending your user to a default activity. It’s not chaning depending on your notification’s content. But you might want to change activity and direct your user to different activities.

In order to do this, you must create a CustomNotificationReceiver which extends BradcastReceiver class. And don’t forget to change package name to yours.

First you must add these colored lines to your AndroidManifest.xml file just after the ParseBroadcastReceiver.

<!– PARSE PUSH NOTIFICATION REQUIREMENTS –>

<service android:name=”com.parse.PushService” />

<receiver android:name=”com.parse.ParseBroadcastReceiver” >
<intent-filter>
<action android:name=”android.intent.action.BOOT_COMPLETED” />
<action android:name=”android.intent.action.USER_PRESENT” />
</intent-filter>
</receiver>
<receiver android:name=”com.your.package.name.CustomNotificationReceiver” android:exported=”false”>
<intent-filter>
<action android:name=”com.your.package.name.CUSTOM_NOTIFICATION” />
</intent-filter>
</receiver>
<receiver
android:name=”com.parse.GcmBroadcastReceiver”
android:permission=”com.google.android.c2dm.permission.SEND” >
<intent-filter>
<action android:name=”com.google.android.c2dm.intent.RECEIVE” />
<action android:name=”com.google.android.c2dm.intent.REGISTRATION” />

<category android:name=”com.your.package.name” />
</intent-filter>
</receiver>

If you’ve added these lines you must create a CustomNotificationReceiver. Before that you should delete this line from your app class.

PushService.setDefaultPushCallback(this, MainActivity.class, R.drawable.ic_launcher);

Your CustomNotificationReceiver should be like that

import org.json.JSONException;
import org.json.JSONObject;

import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.media.RingtoneManager;
import android.net.Uri;
import android.support.v4.app.NotificationCompat;

// You must change these imports to yours
import com.inventio.android.uludag.MainActivity; 

import com.inventio.android.uludag.R;

public class CustomNotificationReceiver extends BroadcastReceiver {

NotificationCompat.Builder mBuilder;
Intent resultIntent;
int mNotificationId = 001;
Uri notifySound;

String alert; // This is the message string that send from push console

@Override
public void onReceive(Context context, Intent intent) {

//Get JSON data and put them into variables
try {

JSONObject json = new JSONObject(intent.getExtras().getString(
“com.parse.Data”)); 

alert = json.getString(“alert”).toString();

} catch (JSONException e) {

}

//You can specify sound
notifySound = RingtoneManager

.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);

mBuilder = new NotificationCompat.Builder(context);
mBuilder.setSmallIcon(R.drawable.ic_launcher); //You can change your icon
mBuilder.setContentText(alert);
mBuilder.setContentTitle(“Your notification title”);
mBuilder.setSound(notifySound);
mBuilder.setAutoCancel(true);

// this is the activity that we will send the user, change this to anything you want
resultIntent = new Intent(context, MainActivity.class);

PendingIntent resultPendingIntent = PendingIntent.getActivity(context,
0, resultIntent, PendingIntent.FLAG_UPDATE_CURRENT);

mBuilder.setContentIntent(resultPendingIntent);

NotificationManager notificationManager = (NotificationManager) context
.getSystemService(context.NOTIFICATION_SERVICE);

notificationManager.notify(mNotificationId, mBuilder.build());

}

}

And also you should send your notification in JSON format, not text. This is a sample of this JSON format. You can increase the strings that you send. Customize them for your usage.

{
“action”:”com.inventio.android.uludag.CUSTOM_NOTIFICATION”, 
“alert”: “This is your notification message”
}