My Map Application

Few days before I created one app, It's a map application. It's not a great application, but simple application.

To load the data from the web, data has too be listed, when you select or click particular user data, load the map with marker.

I tried with my knowledge, but don't expect too much. But it will be useful for beginners and peoples who are trying the map at first time.

Get from the my GITHUB

Store and Get the data from Cache in Android.

It's Interesting, most of peoples thinks about the database, shared preferences and content providers for offline data storage.

Some different came like data must be stored in cache, when app offline, retrieve data from the cache.

Just try this, It might be useful for you.

public String temp_filename = "user_data.txt";
public File tempFile;

// To Store the file in Cache
public void storeToCache(Context context, String data) {
        if (data != null && !data.equals("")) {
            FileWriter writer;
            try {
                writer = new FileWriter(getCacheFile(context));
                Log.d(TAG, "stored to cache");
            } catch (IOException e) {

// To Check the file is exist or not
public boolean isCacheExist(Context context) {
        boolean isExist;
        isExist = getCacheFile(context).exists();

Validate the URL

Have a great day friends. Today will look up validating the URL. How to do this?

Most of times, your internet will be working, but sometimes URL to be busy or invalid. In this case, we follow this thing.

 public boolean isServerReachable(Context context, String url) {
        ConnectivityManager connMan = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo netInfo = connMan.getActiveNetworkInfo();
        if (netInfo != null && netInfo.isConnected()) {
            try {
                URL urlServer = new URL(url);
                    HttpsURLConnection urlConn = (HttpsURLConnection) urlServer.openConnection();
                    TLSSocketFactory socketFactory = new TLSSocketFactory();
                    urlConn.setConnectTimeout(3000); //<- 3Seconds Timeout
                    if (ur…

Send the data to one app to another app using intent and broadcast - Part 2

Previous post I explain about the sharing the data using broadcast. This post about to share the data using the intents.
By using Intent

In First Application

Intent intent = new Intent(); intent.setClassName("", ""); intent.putExtra("EXTRA_ORDERID", "#4FGT784"); intent.putExtra("EXTRA_ORDERNOTES", "No warranty for this product"); intent.putExtra("EXTRA_ORDERAMOUNT", "270");

PackageManager packageManager = getPackageManager(); List<ResolveInfo> activities = packageManager.queryIntentActivities(intent, 0); boolean isIntentSafe = activities.size() > 0;
if (isIntentSafe) { startActivity(intent); } else { Toast.makeText(MainActivity.this, "Application not installed", Toast.LENGTH_LONG).show(); }
In Second Application
Bundle vals = getIntent().getExtras(); if (vals != null) { String orderId = vals.getString("EXTRA_ORDERID", ""); String orderNotes = val…

Send the data to one app to another app using intent and broadcast - Part 1

Hi Friends, Have a great day. It's my 75th blog. I'm very slow, but I'm post only necessary and important posts only, hope so.

This time we'll look some manual broadcast message sending from another application, best way to for testing the notifications.

By Using send broadcast.
In First Application
ComponentName componentName = new ComponentName("", "");
Intent intent = new Intent();
String message = "Order ID:  #AER46798 ";
intent.putExtra("EXTRA_TITLE", "New Order Received");
intent.putExtra("EXTRA_MESSAGE", message);

In Second Application Receiver
public class NotificationReceiver extends BroadcastReceiver {

    public static String TAG = "PCM";

    public void onReceive(Context context, Intent intent) {
        Log.i(TAG, "message_received");
        String title = "&…

Patterns and Regular Expressions

In Java usually validate with some specific characters, we should use Regular Expressions.

Same way in Android, here we use Patterns.

More info about the Patterns: Click here

In android EditText, we can use custom input filter to perform this.

This is for maximum input digits before and after decimal pointer.


public class CustomInputFilter implements InputFilter {
    int maxDigitsBeforeDecimalPoint;
    int maxDigitsAfterDecimalPoint;

    public CustomInputFilter(int maxDigitsBeforeDecimalPoint, int maxDigitsAfterDecimalPoint) {
        this.maxDigitsBeforeDecimalPoint = maxDigitsBeforeDecimalPoint;
        this.maxDigitsAfterDecimalPoint = maxDigitsAfterDecimalPoint;

    public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) {
        StringBuilder builder = new StringBuilder(dest);
        builder.replace(dstart, dend, source
                .subSequence(start, end).toString());
        if (!builder.toStri…

Webview Tricks and Tips

To enable back button should be not close the application and web pages navigation only,

    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            return true;
        return super.onKeyDown(keyCode, event);

Webview settings:

        WebSettings webSetting = sWebview.getSettings();
        //Set whether the DOM storage API is enabled.
        sWebview.setWebChromeClient(new WebChromeClient());
        sWebview.setWebViewClient(new MyWebViewClient());

To interact between Java and Javascript:


import android.util.Log;
import android.webkit.JavascriptInterface;
import android.webkit.WebView;

public class WebAppInterface {
    Activity activity;
    ResultInterface resultInterface;
    WebView webView…