Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8910927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:49:09+00:00 2026-06-15T03:49:09+00:00

I am having an issue when trying to access a remote database. This issue

  • 0

I am having an issue when trying to access a remote database. This issue only occurs on ICS or above, but runs perfectly fine on older Android. I can’t figure this one out for the life of me, and have been stuck on it for weeks. I really need to figure this out so I can then use the solution here in another app of mine that is far more important.

Any help would be greatly appreciated. If more information is needed, just let me know.

Now the app wont even launch, getting the following when launch:

11-30 15:42:46.970: W/dalvikvm(10028): threadid=1: thread exiting with uncaught exception (group=0x40d04210)
11-30 15:42:46.970: E/AndroidRuntime(10028): FATAL EXCEPTION: main
11-30 15:42:46.970: E/AndroidRuntime(10028): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.defsoftsol.db.check/com.defsoftsol.db.check.MainActivity}: java.lang.NullPointerException
11-30 15:42:46.970: E/AndroidRuntime(10028):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1880)
11-30 15:42:46.970: E/AndroidRuntime(10028):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
11-30 15:42:46.970: E/AndroidRuntime(10028):    at android.app.ActivityThread.access$600(ActivityThread.java:123)
11-30 15:42:46.970: E/AndroidRuntime(10028):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
11-30 15:42:46.970: E/AndroidRuntime(10028):    at android.os.Handler.dispatchMessage(Handler.java:99)
11-30 15:42:46.970: E/AndroidRuntime(10028):    at android.os.Looper.loop(Looper.java:137)
11-30 15:42:46.970: E/AndroidRuntime(10028):    at android.app.ActivityThread.main(ActivityThread.java:4428)
11-30 15:42:46.970: E/AndroidRuntime(10028):    at java.lang.reflect.Method.invokeNative(Native Method)
11-30 15:42:46.970: E/AndroidRuntime(10028):    at java.lang.reflect.Method.invoke(Method.java:511)
11-30 15:42:46.970: E/AndroidRuntime(10028):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:787)
11-30 15:42:46.970: E/AndroidRuntime(10028):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:554)
11-30 15:42:46.970: E/AndroidRuntime(10028):    at dalvik.system.NativeStart.main(Native Method)
11-30 15:42:46.970: E/AndroidRuntime(10028): Caused by: java.lang.NullPointerException
11-30 15:42:46.970: E/AndroidRuntime(10028):    at android.app.Activity.findViewById(Activity.java:1794)
11-30 15:42:46.970: E/AndroidRuntime(10028):    at com.defsoftsol.db.check.MainActivity.<init>(MainActivity.java:43)
11-30 15:42:46.970: E/AndroidRuntime(10028):    at java.lang.Class.newInstanceImpl(Native Method)
11-30 15:42:46.970: E/AndroidRuntime(10028):    at java.lang.Class.newInstance(Class.java:1319)
11-30 15:42:46.970: E/AndroidRuntime(10028):    at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
11-30 15:42:46.970: E/AndroidRuntime(10028):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1871)
11-30 15:42:46.970: E/AndroidRuntime(10028):    ... 11 more

UPDATED CODE: (Now the code for entire app)

public class MainActivity extends Activity {

String deviceID="",dateStamp="",buff="",db_id="",db_device_id="",db_install_date="";       
byte[] data;    
HttpPost httppost;    
StringBuffer buffer;    
HttpResponse response;    
HttpClient httpclient;    
InputStream inputStream;    
List<NameValuePair> nameValuePairs;
int ID,activeinstalls;
long diff;
TableLayout tl=(TableLayout)findViewById(R.id.db_data);

public void onCreate(Bundle savedInstanceState) 
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    Button refresh = (Button)findViewById(R.id.btnrefresh);
    refresh.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            new MyAsyncTask(MainActivity.this).execute();

        }
    });
}

@SuppressWarnings("unused") 
public class MyAsyncTask extends AsyncTask<Void, Void, Void> 
{ 

    ProgressDialog mProgressDialog;
    private Context context;

    public MyAsyncTask(Context context) { 
        this.context = context;
    }

    @Override
    protected void onPostExecute(Void result) {
        mProgressDialog.dismiss();
    } 

    @Override 
    protected void onPreExecute() {
        mProgressDialog = ProgressDialog.show(MainActivity.this, "Loading...", "Data is Loading..."); 
    } 

    @Override
    protected Void doInBackground(Void... params) {
        update(); 
        return null; 
    }
}

private final SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); 
private final long ONE_DAY = 24 * 60 * 60 * 1000;

@SuppressWarnings("unused")
public void update()
{
    int activeinstalls = 0;
    Date now = new Date();
    dateStamp = formatter.format(now);

    runOnUiThread(new Runnable(){ 
        @Override 
        public void run(){ 
            UISetup();
        }
    });

    ID = 1;
    try
    {
        do
        {
            try 
            {                    
                httpclient = new DefaultHttpClient();                    
                httppost = new HttpPost("http://#.#.#.#/***.php"); //Address cut for server security                    

                nameValuePairs = new ArrayList<NameValuePair>(1);                   
                nameValuePairs.add(new BasicNameValuePair("_id", String.valueOf(ID)));                    
                httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
                response = httpclient.execute(httppost);                    
                inputStream = response.getEntity().getContent();                     
                data = new byte[256];                     
                buffer = new StringBuffer();                    
                int len = 0;                    
                while (-1 != (len = inputStream.read(data)) )                    
                {                        
                    buffer.append(new String(data, 0, len));                    
                }
                inputStream.close();
            } catch (Exception e) {                    
                Toast.makeText(MainActivity.this, "error"+e.toString(), Toast.LENGTH_LONG).show();                
                e.printStackTrace();
            }

            if(buffer.charAt(0)=='Y')
            {
                ID++;
                buff = buffer.toString();
                db_id = buff.substring(1, buff.indexOf("."));
                db_device_id = buff.substring(buff.indexOf(".")+1, buff.indexOf(","));
                db_install_date = buff.substring(buff.indexOf(",")+1, buff.length());

                Date before = null;
                try {
                    before = (Date)formatter.parse(db_install_date);
                } catch (ParseException e) {
                    e.printStackTrace();
                }
                diff = now.getTime() - before.getTime(); 

                runOnUiThread(new Runnable(){ 
                    @Override 
                    public void run(){ 
                        UIAdd(diff,db_id,db_device_id,db_install_date);
                    }
                });

            } else { //IF buffer returns N
                //  TODO: Fill in
            }
        } while(buffer.charAt(0)=='Y');

        UIFinish();

    } catch(Exception err) {
        err.printStackTrace();
    }
}
@SuppressWarnings("deprecation")
public void UISetup()
{
    tl.removeAllViews();
    dbline();
    TableRow titr = new TableRow(this); 
    titr.setLayoutParams(new LayoutParams( LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT)); 
    TextView dbid0 = new TextView(this); 
    TextView dbdevid0 = new TextView(this);
    TextView dbindate0 = new TextView(this);
    dbid0.setText("|   " + "_id");
    dbdevid0.setText("|   " + "device_id");
    dbindate0.setText("|   "+ "install_date"+"    |");

    titr.addView(dbid0); 
    titr.addView(dbdevid0);
    titr.addView(dbindate0);
    tl.addView(titr, new TableLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
    dbline();
}
@SuppressWarnings("deprecation")
public void UIAdd(long diffr, String dbidn,String did,String idate)
{
    long days;
    days = diffr / ONE_DAY;
    TableRow tr = new TableRow(this); 
    tr.setLayoutParams(new LayoutParams( LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT)); 
    TextView dbid = new TextView(this); 
    TextView dbdevid = new TextView(this);
    TextView dbindate = new TextView(this);
    dbid.setText("|   " + dbidn);
    dbdevid.setText("|   " + did);
    dbindate.setText("|   " + idate+"   |");

    if(days <= 7)
    {
        activeinstalls++;
        if(days <= 3) 
        {
            dbid.setTextColor(Color.GREEN); 
            dbdevid.setTextColor(Color.GREEN);
            dbindate.setTextColor(Color.GREEN);
        } else {
            dbid.setTextColor(Color.MAGENTA);
            dbdevid.setTextColor(Color.MAGENTA);
            dbindate.setTextColor(Color.MAGENTA);
        }

    } else {
        dbid.setTextColor(Color.RED); 
        dbdevid.setTextColor(Color.RED);
        dbindate.setTextColor(Color.RED);
    }

    tr.addView(dbid); 
    tr.addView(dbdevid);
    tr.addView(dbindate);
    tl.addView(tr, new TableLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
}
public void UIFinish()
{
    dbline();

    TextView te = (TextView)findViewById(R.id.totalentries);
    te.setText(String.valueOf(ID-1));
    TextView au = (TextView)findViewById(R.id.activeusers);
    au.setText(String.valueOf(activeinstalls));
}
@SuppressWarnings("deprecation")
public void dbline()
{
    TableLayout tl=(TableLayout)findViewById(R.id.db_data);
    TableRow tr = new TableRow(this); 
    tr.setLayoutParams(new LayoutParams( LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT)); 
    TextView dbid = new TextView(this); 
    TextView dbdevid = new TextView(this);
    TextView dbindate = new TextView(this);
    dbid.setText("+---------");
    dbdevid.setText("+-------------------------------");
    dbindate.setText("+--------------------+");

    tr.addView(dbid); 
    tr.addView(dbdevid);
    tr.addView(dbindate);
    tl.addView(tr, new TableLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
}

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T03:49:10+00:00Added an answer on June 15, 2026 at 3:49 am

    You get an Exception in the try block, and don’t initialize buffer. That’s why you get the Null pointer.

    You should put everything in the try-catch. Or think better about how to handle it.

    And, you also should output the error from the try catch in the console. And show it to us. We can look at it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Having an issue with random individuals trying to access an intranet site with a
I'm having this issue when trying to use an ASPX page from a referenced
I am trying to connect remote mysql i am having typical issue. $conn =
I'm trying to access Windows XP's Application Data - but I'm having a slight
I'm having an issue trying to access a web service through Delphi. I've consumed
We’re having an issue with Googlebot trying to access a URL on an Ajax
I'm having a bit of an issue. I'm trying to run this VB6 application
i'm having an issue comparing a date in an access database. basically i'm parsing
I am having an issue trying to make a small text-fantasy type game involving
I am having an issue trying to deal with timezones in the JQuery date/time

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.