Skip to content

Instantly share code, notes, and snippets.

public void storeProcessID(Context context, int processid) {
final SharedPreferences prefs = getPushPreferences(context);
SharedPreferences.Editor editor = prefs.edit();
editor.putInt(PROCESS_ID, processid);
editor.apply();
}
public int getStoredProcessID(Context context){
final SharedPreferences prefs = getPushPreferences(context);
@MustafaFerhan
MustafaFerhan / evaluateJavascript String problem
Last active November 4, 2021 06:59
Webview evaluateJavascript JSON problem
import com.google.gson.JsonParser;
/**
* Created by mustafaferhan on 22/05/15.
*
* When the working on webview.evaluateJavascript() method, it return as String on onReceiveValue() method.
* The problem is this String not convertable for JSON Object.
* Error Log:
* org.json.JSONException: Expected literal value at character 1 of or
* JSONException: Value of type java.lang.String cannot be converted to JSONObject
@MustafaFerhan
MustafaFerhan / shareintent
Created January 12, 2015 21:37
Android Share Intent
private boolean share(String appName, String url, String text) {
List<Intent> targetedShareIntents = new ArrayList<Intent>();
Intent share = new Intent(android.content.Intent.ACTION_SEND);
share.setType("text/plain");
List<ResolveInfo> resInfo = getPackageManager().queryIntentActivities(share, 0);
if (resInfo.size() > 0){
for (ResolveInfo info : resInfo) {
Intent targetedShare = new Intent(android.content.Intent.ACTION_SEND);