inflacort
inflacort

Reputation: 23

android programming using internet to access web site

I want to access the web site I want to retrieve information from website. I have found a solution for that but this application is unfortunately stopped any ideas?

package pete.android.study;

Upvotes: 0

Views: 176

Answers (3)

Raghav Sood
Raghav Sood

Reputation: 82583

Your Activity name and package is wrong.

In your manifest, your Main Activity is specified to be com.example.ipk.MainActivity. However, the Activity you posted, which I'm assuming is the one you want as your Main Activity, is pete.android.study.JSoupStudyActivity.

To fix this, change the

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.ipk"

to

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="pete.android.study"

And change:

    <activity android:name=".MainActivity">
        <intent-filter>
            <category android:name="android.intent.category.LAUNCHER" >
            </category>

            <action android:name="android.intent.action.MAIN" >
            </action>
        </intent-filter>
    </activity>

to

    <activity android:name=".JSoupStudyActivity">
        <intent-filter>
            <category android:name="android.intent.category.LAUNCHER" >
            </category>

            <action android:name="android.intent.action.MAIN" >
            </action>
        </intent-filter>
    </activity>

Upvotes: 1

Waza_Be
Waza_Be

Reputation: 39578

I suspect a NetworkOnMainThreadException

The exception that is thrown when an application attempts to perform a networking operation on its main thread.

This is only thrown for applications targeting the Honeycomb SDK or higher. Applications targeting earlier SDK versions are allowed to do networking on their main event loop threads, but it's heavily discouraged. See the document Designing for Responsiveness.

Runnable blogSearch = new Runnable() {
      public void run() {
         final String text = getBlogStats();
         JSoupStudyActivity.this.runOnUiThread(new Runnable() {
            @Override
            public void run() {
               ((TextView) findViewById(R.id.tv)).setText(text);
            }
         });
      }
   };

Thread thread = new Thread(null, blogSearch, "MyThread");
thread.start();

Upvotes: 0

Mohsin Naeem
Mohsin Naeem

Reputation: 12642

android OS >=3.0 does not allow Network Requests on Main UI thread.

you can use

AsyncTask for this purpose.

Upvotes: 0

Related Questions