checking and Installing new update if internet connection available

2 posts, 0 answers
  1. Ashfaq
    Ashfaq avatar
    1 posts
    Member since:
    Feb 2015

    Posted 14 Feb 2015 Link to this post

    Dear friends,
    I have an application to display some details in the main activity all i want to do is check for update in play store and if there is update application automatically.Please help me to do so since im new in android.


    Mainactivity.java
    import android.app.Fragment;
    import android.content.Intent;
    import android.os.Bundle;
    import android.view.LayoutInflater;
    import android.view.View;
    import android.view.ViewGroup;
    import android.view.animation.AnimationUtils;
    import android.widget.Button;
    import android.widget.ImageView;
    import android.widget.Toast;

    public class Ongoing extends Fragment {
    // flag for Internet connection status
        Boolean isInternetPresent = false;
        // Connection detector class
         
        ConnectionDetector cd;
    public Ongoing(){}

    @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container,
                Bundle savedInstanceState) {
    getActivity().setTitle("Ongoing Projects");
            View rootView = inflater.inflate(R.layout.ongoing_frag, container, false);
           
           
            cd = new ConnectionDetector(getActivity()); 
            isInternetPresent = cd.isConnectingToInternet();
            
            if (isInternetPresent) {
                // Internet Connection is Present
                // make HTTP requests
            Toast.makeText(getActivity(), "You have Internet", Toast.LENGTH_SHORT).show();
           
                                
                   
           
                
            } else {
                // Internet connection is not present
                // Ask user to connect to Internet
            Toast.makeText(getActivity(), "You dont Internet", Toast.LENGTH_SHORT).show();
            }
            
                   
            return rootView;
        
            
    }

    }

  2. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 18 Feb 2015 Link to this post

    Hello Ashfaq,

    If you are building a hybrid app, then you will need a plugin for this task. If this code is from a custom plugin you are building, I would suggest posting your query on the Android developer forums.

    If you are looking for a general approach to updating your hybrid application from within Google Play, then you can define a service that regularly checks for updates of your app and when a new update is detected, prompts the user to install it. You can use the Market Cordova plugin to open Google Play or AppStore from within your application.

    Regards,
    Tina Stancheva
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top