Experts, Any help here?

Thanks

On Oct 20, 8:23 am, Kiran <[email protected]> wrote:
> Hi,
> I have the following code in Oncreate of my activity:
>
> *************************************************************************** 
> *********
>    static String linkUrl = "http://www.google.com/";;
>
>        protected void onCreate(Bundle savedInstanceState) {
>                super.onCreate(savedInstanceState);
>
>                PowerManager pm = (PowerManager) getSystemService
> (Context.POWER_SERVICE);
>                PowerManager.WakeLock wl = pm.newWakeLock
> (PowerManager.SCREEN_DIM_WAKE_LOCK, "My Tag");
>                wl.acquire();
>
>        try {
>                URL connectURL = new URL(linkUrl);
>                HttpURLConnection conn = (HttpURLConnection)
> connectURL.openConnection();
>                DataInputStream dis = new DataInputStream
> (conn.getInputStream
> ());
>                byte[] data = new byte[1024];
>                int len = dis.read(data, 0, 1024);
>                dataText = new String(data, 0, len);
>        }
>        catch(Exception e)
>        {
>            Log.e(TAG, "Exception");
>            return;
>        }
>
>        TextView bodyText = (EditText) findViewById
> (R.id.android_fetchtext);
>        bodyText.setText(dataText);
>        setContentView(R.layout.notes_fetch);
>        wl.release();
>        }
>
> *************************************************************************** 
> *********
> I declared the following permissions in manifest:
> *************************************************************************** 
> *********
>    <uses-permission android:name="android.permission.INTERNET" />
>    <uses-permission android:name="android.permission.WAKE_LOCK"/>
> *************************************************************************** 
> *********
> Here is my xml layout file:
> *************************************************************************** 
> *********
> <?xml version="1.0" encoding="utf-8"?>
> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/
> android"
>      android:layout_width="wrap_content"
>        android:layout_height="wrap_content">
>
>    <ListView android:id="@+id/android:fetchlist"
>          android:layout_width="wrap_content"
>                android:layout_height="wrap_content"/>
>        <TextView android:id="@+id/android:fetchtext"
>          android:layout_width="wrap_content"
>                android:layout_height="wrap_content"/>
> </LinearLayout>
> *************************************************************************** 
> *********
>
> Problem is, application goes to force close with following error:
> *************************************************************************** 
> *********
> 10-19 22:11:49.404: DEBUG/FetchData(715): Entered OnCreate
> 10-19 22:11:49.413: DEBUG/FetchData(715): Set URL
> 10-19 22:11:49.435: DEBUG/FetchData(715): HttpURLConnection
> 10-19 22:11:49.464: DEBUG/FetchData(715): DIS
> 10-19 22:11:56.013: DEBUG/FetchData(715): Read
> --------------------------------
> 10-19 22:11:59.191: WARN/ActivityManager(574): Launch timeout has
> expired, giving up wake lock!
> ----------------------------------
> 10-19 22:11:59.307: WARN/ActivityManager(574): Activity idle timeout
> for HistoryRecord{438d4478 com.android.demo.notepad3/.FetchData}
> -----------------------------------
> 10-19 22:12:01.455: DEBUG/AndroidRuntime(715): Shutting down VM
>
> 10-19 22:12:01.455: WARN/dalvikvm(715): threadid=3: thread exiting
> with uncaught exception (group=0x4001aa28)
> 10-19 22:12:01.465: ERROR/AndroidRuntime(715): Uncaught handler:
> thread main exiting due to uncaught exception
> 10-19 22:12:01.834: ERROR/AndroidRuntime(715):
> java.lang.RuntimeException: Unable to start activity ComponentInfo
> {com.android.demo.notepad3/com.android.demo.notepad3.FetchData}:
> java.lang.NullPointerException
> 10-19 22:12:01.834: ERROR/AndroidRuntime(715):     at
> android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
> 2401)
> 10-19 22:12:01.834: ERROR/AndroidRuntime(715):     at
> android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:
> 2417)
> 10-19 22:12:01.834: ERROR/AndroidRuntime(715):     at
> android.app.ActivityThread.access$2100(ActivityThread.java:116)
> 10-19 22:12:01.834: ERROR/AndroidRuntime(715):     at
> android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
> 10-19 22:12:01.834: ERROR/AndroidRuntime(715):     at
> android.os.Handler.dispatchMessage(Handler.java:99)
> 10-19 22:12:01.834: ERROR/AndroidRuntime(715):     at
> android.os.Looper.loop(Looper.java:123)
> 10-19 22:12:01.834: ERROR/AndroidRuntime(715):     at
> android.app.ActivityThread.main(ActivityThread.java:4203)
> 10-19 22:12:01.834: ERROR/AndroidRuntime(715):     at
> java.lang.reflect.Method.invokeNative(Native Method)
> 10-19 22:12:01.834: ERROR/AndroidRuntime(715):     at
> java.lang.reflect.Method.invoke(Method.java:521)
> 10-19 22:12:01.834: ERROR/AndroidRuntime(715):     at
> com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run
> (ZygoteInit.java:791)
> 10-19 22:12:01.834: ERROR/AndroidRuntime(715):     at
> com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
> 10-19 22:12:01.834: ERROR/AndroidRuntime(715):     at
> dalvik.system.NativeStart.main(Native Method)
> 10-19 22:12:01.834: ERROR/AndroidRuntime(715): Caused by:
> java.lang.NullPointerException
> 10-19 22:12:01.834: ERROR/AndroidRuntime(715):     at
> com.android.demo.notepad3.FetchData.onCreate(FetchData.java:97)
> 10-19 22:12:01.834: ERROR/AndroidRuntime(715):     at
> android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:
> 1123)
> 10-19 22:12:01.834: ERROR/AndroidRuntime(715):     at
> android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
> 2364)
> 10-19 22:12:01.834: ERROR/AndroidRuntime(715):     ... 11 more
> 10-19 22:12:02.124: INFO/Process(574): Sending signal. PID: 715 SIG: 3
> 10-19 22:12:02.134: INFO/dalvikvm(715): threadid=7: reacting to signal
> 3
> 10-19 22:12:02.134: ERROR/dalvikvm(715): Unable to open stack trace
> file '/data/anr/traces.txt': Permission denied
> 10-19 22:12:02.675: INFO/ARMAssembler(574): generated
> scanline__00000077:03515104_00001001_00000000 [ 64 ipp] (84 ins) at
> [0x2447f0:0x244940] in 3552128 ns
>
> *************************************************************************** 
> *********
> Any help is deeply appreciated.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to