Tuesday, January 19, 2016

Open application if it is exist, or open Play Store application for install it in android

private void open() {
    openApplication(getActivity(), "com.app.package.here");
}

public void openApplication(Context context, String packageN) {
    Intent i = context.getPackageManager().getLaunchIntentForPackage(packageN);
    if (i == null) {
        i.addCategory(Intent.CATEGORY_LAUNCHER);
        context.startActivity(i);
    } else {
        try {
            context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + packageN)));
        }
        catch (android.content.ActivityNotFoundException anfe) {
            context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=" + packageN)));
        }
    }
}

Difference START_STICKY and START_NOT_STICKY in android

Difference:
the system will try to re-create your service after it is killed
the system will not try to re-create your service after it is killed

Standard example:
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    return START_STICKY;
}

Tuesday, January 12, 2016

How to get the SHA1 fingerprint certificate in android studio for debug mode?

First open cmd  then  get  bin  location  like bellow
C:\Program Files\Java\jdk1.8.0\bin>

then type 

keytool -list -v -keystore C:\Users\yourPC_username\.android\debug.keystore -alias androiddebugkey -storepass android -keypass android

example = keytool -list -v -keystore C:\Users\A\.android\debug.keystore -alias androiddebugkey -storepass android -keypass android

press enter 

get your result.