Results 1 to 12 of 12
Like Tree1Likes
  • 1 Post By Norm

Thread: Threads, loadImageFromNetwork - Unfortunately <application> has stopped

  1. #1
    Zarah is offline Senior Member
    Join Date
    Mar 2014
    Posts
    116
    Rep Power
    0

    Default Threads, loadImageFromNetwork - Unfortunately <application> has stopped

    Hello,

    My application does not give any compile-time error and it does show the only activity it should show. It is a simple activity with a button (and an imageview). When the user clicks on the button, it should download an image from the network and display it in the imageView. When I click on the button, it just says, "Unfortunately, Concurrency has stopped."

    I am reading up on threads in android and I got to know about the rules of not performing intensive operations in the UI thread and not manipulating the UI from outside the UI thread. I was practicing this.

    I am not yet familiar with how to read logcats. I am posting my logcat and it will be great if somebody can read it and point out what's causing the problem.

    Moreover, the implementation of loadImageFromNetwork() is not coded by me. I just copied it from internet. So I don't have an understanding of its call to the decodeStream() method. It was not my concern for the moment.

    Note:- I had also posted this on stackoverflow.com and the answers could not fix the problem. Here is the link.

    MainActivity.java:-

    Java Code:
    package com.example.concurrency;
    
    import java.io.InputStream;
    import java.net.URL;
    
    import android.app.Activity;
    import android.graphics.Bitmap;
    import android.graphics.BitmapFactory;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.ImageView;
    
    public class MainActivity extends Activity {
        public static final String key_name="com.practice.firstApp.key";
        ImageView imageView;
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
        }
        
        public void downloadImage(View v){
        	new Thread(new Runnable(){
        		
        		private Bitmap loadImageFromNetwork(String url){
        			try {
        			Bitmap bitmap = BitmapFactory.decodeStream((InputStream)new URL(url).getContent());
        			return bitmap;
        			} catch (Exception e) {
        			e.printStackTrace();
        			}
        			return null;
        			}
        		
        		public void run(){
        			final Bitmap bitmap= loadImageFromNetwork("http://www.google.com/imgres?imgurl=http%3A%2F%2Fupload.wikimedia.org%2Fwikipedia%2Fcommons%2F7%2F7a%2FBasketball.png&imgrefurl=http%3A%2F%2Fcommons.wikimedia.org%2Fwiki%2FFile%3ABasketball.png&h=340&w=340&tbnid=EJmjEDyJzrhAuM%3A&zoom=1&docid=C_hn8nOgsGmuwM&hl=en&ei=Q0o2U93LNcaIygH4mICQBQ&tbm=isch&ved=0CHwQhBwwBg&iact=rc&dur=3875&page=1&start=0&ndsp=14");
        		    imageView.post(new Runnable(){
        		    	public void run(){
        		    		imageView.setImageBitmap(bitmap);
        		    	}
        		    });
        		}
        	}).start();
        }
    }
    Activity_main.xml:-

    Java Code:
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        
        android:layout_width="match_parent"
        android:layout_height="match_parent"
    
        tools:context=".MainActivity" >
        
         <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
    
            android:text="@string/Button_MainActivity"
    
            android:onClick="downloadImage"/>
    
    </RelativeLayout>
    Strings.xml:-

    Java Code:
    <?xml version="1.0" encoding="utf-8"?>
    <resources>
    
        <string name="app_name">Concurrency</string>
        <string name="action_settings">Settings</string>
        <string name="hello_world">Hello world!</string>
        <string name="Button_MainActivity">Download</string>
    
    </resources>

    Manifest.xml:-


    Java Code:
    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.example.concurrency"
        android:versionCode="1"
        android:versionName="1.0" >
        
        <uses-permission android:name="android.permission.INTERNET" />
    	<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    	<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    
        <uses-sdk
            android:minSdkVersion="8"
            android:targetSdkVersion="18" />
    
        <application
            android:allowBackup="true"
            android:icon="@drawable/ic_launcher"
            android:label="@string/app_name"
            android:theme="@style/AppTheme" >
            <activity
                android:name="com.example.concurrency.MainActivity"
                android:label="@string/app_name" >
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
    
                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
            </activity>
        </application>
    
    </manifest>
    LogCat:-

    Here it is; pasting it here was exceeding the allowed character length.
    Last edited by Zarah; 03-29-2014 at 06:39 PM.

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,421
    Rep Power
    25

    Default Re: Threads, loadImageFromNetwork - Unfortunately <application> has stopped

    The contents of the LogCat didn't get posted.
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    Zarah is offline Senior Member
    Join Date
    Mar 2014
    Posts
    116
    Rep Power
    0

    Default Re: Threads, loadImageFromNetwork - Unfortunately <application> has stopped

    Quote Originally Posted by Norm View Post
    The contents of the LogCat didn't get posted.
    There is a link to [Java] 03-29 13:28:13.191: D/AndroidRuntime(1118): >>>>>> AndroidRuntime START com.andr - Pastebin.com, I pasted it there, because pasting it here was exceeding the permissible character length of my post.

  4. #4
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,421
    Rep Power
    25

    Default Re: Threads, loadImageFromNetwork - Unfortunately <application> has stopped

    Can you run it again. Clear the LogCat (there is a button) before pressing the button and then the contents of the LogCat will be smaller and show the error without all the Android startup messages.
    If you don't understand my response, don't ignore it, ask a question.

  5. #5
    Zarah is offline Senior Member
    Join Date
    Mar 2014
    Posts
    116
    Rep Power
    0

    Default Re: Threads, loadImageFromNetwork - Unfortunately <application> has stopped

    Can you run it again. Clear the LogCat (there is a button) before pressing the button and then the contents of the LogCat will be smaller and show the error without all the Android startup messages.
    Yes, here! I cleared the LogCat and then run it.

  6. #6
    Zarah is offline Senior Member
    Join Date
    Mar 2014
    Posts
    116
    Rep Power
    0

    Default Re: Threads, loadImageFromNetwork - Unfortunately <application> has stopped

    Can you run it again. Clear the LogCat (there is a button) before pressing the button and then the contents of the LogCat will be smaller and show the error without all the Android startup messages.
    Yes, here! I cleared the LogCat and then run it.

  7. #7
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,421
    Rep Power
    25

    Default Re: Threads, loadImageFromNetwork - Unfortunately <application> has stopped

    Then after running the app and getting the error, copy the contents of the LogCat and paste it here.
    For example:
    11-07 14:43:47.921: E/Trace(2512): error opening trace file: No such file or directory (2)
    11-07 14:43:47.921: E/Trace(2512): error opening trace file: No such file or directory (2)
    11-07 14:43:52.541: D/gralloc_vbox86(2512): Emulator without GPU emulation detected.
    11-07 14:43:57.081: I/Choreographer(2512): Skipped 92 frames! The application may be doing too much work on its main thread.
    11-07 14:43:57.873: D/AndroidRuntime(2512): Shutting down VM
    11-07 14:43:57.897: W/dalvikvm(2512): threadid=1: thread exiting with uncaught exception (group=0xa6185908)
    11-07 14:43:58.153: E/AndroidRuntime(2512): FATAL EXCEPTION: main
    11-07 14:43:58.153: E/AndroidRuntime(2512): java.lang.NullPointerException
    11-07 14:43:58.153: E/AndroidRuntime(2512): at com.example.android.fragments.ArticleFragment.upda teArticleView(ArticleFragment.java:65)
    11-07 14:43:58.153: E/AndroidRuntime(2512): at com.example.android.fragments.FragmentBasics.onArt icleSelected(FragmentBasics.java:68)
    11-07 14:43:58.153: E/AndroidRuntime(2512): at com.example.android.fragments.HeadlinesFragment.on ListItemClick(HeadlinesFragment.java:76)
    11-07 14:43:58.153: E/AndroidRuntime(2512): at android.app.ListFragment$2.onItemClick(ListFragmen t.java:160)
    11-07 14:43:58.153: E/AndroidRuntime(2512): at android.widget.AdapterView.performItemClick(Adapte rView.java:298)
    11-07 14:43:58.153: E/AndroidRuntime(2512): at android.widget.AbsListView.performItemClick(AbsLis tView.java:1100)
    11-07 14:43:58.153: E/AndroidRuntime(2512): at android.widget.AbsListView$PerformClick.run(AbsLis tView.java:2749)
    11-07 14:43:58.153: E/AndroidRuntime(2512): at android.widget.AbsListView$1.run(AbsListView.java: 3423)
    11-07 14:43:58.153: E/AndroidRuntime(2512): at android.os.Handler.handleCallback(Handler.java:725 )
    11-07 14:43:58.153: E/AndroidRuntime(2512): at android.os.Handler.dispatchMessage(Handler.java:92 )
    11-07 14:43:58.153: E/AndroidRuntime(2512): at android.os.Looper.loop(Looper.java:137)
    11-07 14:43:58.153: E/AndroidRuntime(2512): at android.app.ActivityThread.main(ActivityThread.jav a:5041)
    11-07 14:43:58.153: E/AndroidRuntime(2512): at java.lang.reflect.Method.invokeNative(Native Method)
    11-07 14:43:58.153: E/AndroidRuntime(2512): at java.lang.reflect.Method.invoke(Method.java:511)
    11-07 14:43:58.153: E/AndroidRuntime(2512): at com.android.internal.os.ZygoteInit$MethodAndArgsCa ller.run(ZygoteInit.java:793)
    11-07 14:43:58.153: E/AndroidRuntime(2512): at com.android.internal.os.ZygoteInit.main(ZygoteInit .java:560)
    11-07 14:43:58.153: E/AndroidRuntime(2512): at dalvik.system.NativeStart.main(Native Method)
    11-07 14:44:04.433: I/Process(2512): Sending signal. PID: 2512 SIG: 9
    If you don't understand my response, don't ignore it, ask a question.

  8. #8
    Zarah is offline Senior Member
    Join Date
    Mar 2014
    Posts
    116
    Rep Power
    0

    Default Re: Threads, loadImageFromNetwork - Unfortunately <application> has stopped

    Then after running the app and getting the error, copy the contents of the LogCat and paste it here.
    03-29 14:19:37.081: D/AndroidRuntime(1341): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
    03-29 14:19:37.081: D/AndroidRuntime(1341): CheckJNI is ON
    03-29 14:19:37.211: D/dalvikvm(1341): Trying to load lib libjavacore.so 0x0
    03-29 14:19:37.241: D/dalvikvm(1341): Added shared lib libjavacore.so 0x0
    03-29 14:19:37.321: D/dalvikvm(1341): Trying to load lib libnativehelper.so 0x0
    03-29 14:19:37.321: D/dalvikvm(1341): Added shared lib libnativehelper.so 0x0
    03-29 14:19:38.691: D/AndroidRuntime(1341): Calling main entry com.android.commands.pm.Pm
    03-29 14:19:38.731: D/AndroidRuntime(1341): Shutting down VM
    03-29 14:19:38.731: D/dalvikvm(1341): Debugger has detached; object registry had 1 entries
    03-29 14:19:39.820: D/AndroidRuntime(1352): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
    03-29 14:19:39.820: D/AndroidRuntime(1352): CheckJNI is ON
    03-29 14:19:40.173: D/dalvikvm(1352): Trying to load lib libjavacore.so 0x0
    03-29 14:19:40.200: D/dalvikvm(1352): Added shared lib libjavacore.so 0x0
    03-29 14:19:40.330: D/dalvikvm(1352): Trying to load lib libnativehelper.so 0x0
    03-29 14:19:40.330: D/dalvikvm(1352): Added shared lib libnativehelper.so 0x0
    03-29 14:19:41.620: D/AndroidRuntime(1352): Calling main entry com.android.commands.am.Am
    03-29 14:19:41.640: D/dalvikvm(1352): Note: class Landroid/app/ActivityManagerNative; has 163 unimplemented (abstract) methods
    03-29 14:19:41.680: I/ActivityManager(277): START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.example.concurrency/.MainActivity} from pid 1352
    03-29 14:19:41.803: I/WindowManager(277): Screenshot Window{41940e50 u0 com.android.launcher/com.android.launcher2.Launcher} was all black! mSurfaceLayer=21005 minLayer=21005 maxLayer=21005
    03-29 14:19:42.070: D/dalvikvm(277): GC_FOR_ALLOC freed 634K, 18% free 6449K/7840K, paused 263ms, total 268ms
    03-29 14:19:42.240: W/dalvikvm(1364): PR_CAPBSET_DROP 0 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
    03-29 14:19:42.240: W/dalvikvm(1364): PR_CAPBSET_DROP 1 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
    03-29 14:19:42.271: W/dalvikvm(1364): PR_CAPBSET_DROP 2 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
    03-29 14:19:42.271: W/dalvikvm(1364): PR_CAPBSET_DROP 3 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
    03-29 14:19:42.271: W/dalvikvm(1364): PR_CAPBSET_DROP 4 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
    03-29 14:19:42.271: W/dalvikvm(1364): PR_CAPBSET_DROP 5 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
    03-29 14:19:42.271: W/dalvikvm(1364): PR_CAPBSET_DROP 6 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
    03-29 14:19:42.271: W/dalvikvm(1364): PR_CAPBSET_DROP 7 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
    03-29 14:19:42.271: W/dalvikvm(1364): PR_CAPBSET_DROP 8 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
    03-29 14:19:42.271: W/dalvikvm(1364): PR_CAPBSET_DROP 9 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
    03-29 14:19:42.280: W/dalvikvm(1364): PR_CAPBSET_DROP 10 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
    03-29 14:19:42.280: W/dalvikvm(1364): PR_CAPBSET_DROP 11 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
    03-29 14:19:42.280: W/dalvikvm(1364): PR_CAPBSET_DROP 12 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
    03-29 14:19:42.280: W/dalvikvm(1364): PR_CAPBSET_DROP 13 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
    03-29 14:19:42.290: W/dalvikvm(1364): PR_CAPBSET_DROP 14 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
    03-29 14:19:42.290: W/dalvikvm(1364): PR_CAPBSET_DROP 15 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
    03-29 14:19:42.290: W/dalvikvm(1364): PR_CAPBSET_DROP 16 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
    03-29 14:19:42.290: W/dalvikvm(1364): PR_CAPBSET_DROP 17 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
    03-29 14:19:42.290: W/dalvikvm(1364): PR_CAPBSET_DROP 18 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
    03-29 14:19:42.290: W/dalvikvm(1364): PR_CAPBSET_DROP 19 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
    03-29 14:19:42.310: I/ActivityManager(277): Start proc com.example.concurrency for activity com.example.concurrency/.MainActivity: pid=1364 uid=10067 gids={50067, 3003, 1028}
    03-29 14:19:42.321: W/dalvikvm(1364): PR_CAPBSET_DROP 20 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
    03-29 14:19:42.321: W/dalvikvm(1364): PR_CAPBSET_DROP 21 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
    03-29 14:19:42.321: W/dalvikvm(1364): PR_CAPBSET_DROP 22 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
    03-29 14:19:42.321: W/dalvikvm(1364): PR_CAPBSET_DROP 23 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
    03-29 14:19:42.321: W/dalvikvm(1364): PR_CAPBSET_DROP 24 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
    03-29 14:19:42.321: W/dalvikvm(1364): PR_CAPBSET_DROP 25 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
    03-29 14:19:42.330: W/dalvikvm(1364): PR_CAPBSET_DROP 26 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
    03-29 14:19:42.330: W/dalvikvm(1364): PR_CAPBSET_DROP 27 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
    03-29 14:19:42.340: W/dalvikvm(1364): PR_CAPBSET_DROP 28 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
    03-29 14:19:42.340: W/dalvikvm(1364): PR_CAPBSET_DROP 29 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
    03-29 14:19:42.340: W/dalvikvm(1364): PR_CAPBSET_DROP 30 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
    03-29 14:19:42.340: W/dalvikvm(1364): PR_CAPBSET_DROP 31 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
    03-29 14:19:42.350: W/dalvikvm(1364): PR_CAPBSET_DROP 32 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
    03-29 14:19:42.350: W/dalvikvm(1364): PR_CAPBSET_DROP 33 failed: Invalid argument. Please make sure your kernel is compiled with file capabilities support enabled.
    03-29 14:19:42.350: D/dalvikvm(1364): Not late-enabling CheckJNI (already on)
    03-29 14:19:42.390: D/AndroidRuntime(1352): Shutting down VM
    03-29 14:19:42.400: D/dalvikvm(1352): Debugger has detached; object registry had 1 entries
    03-29 14:19:43.830: D/libEGL(1364): loaded /system/lib/egl/libEGL_emulation.so
    03-29 14:19:43.922: D/(1364): HostConnection::get() New Host Connection established 0x2a1cdc68, tid 1364
    03-29 14:19:44.031: D/libEGL(1364): loaded /system/lib/egl/libGLESv1_CM_emulation.so
    03-29 14:19:44.080: D/libEGL(1364): loaded /system/lib/egl/libGLESv2_emulation.so
    03-29 14:19:45.010: W/EGL_emulation(1364): eglSurfaceAttrib not implemented
    03-29 14:19:45.440: D/OpenGLRenderer(1364): Enabling debug mode 0
    03-29 14:19:48.770: I/ActivityManager(277): Displayed com.example.concurrency/.MainActivity: +6s626ms
    03-29 14:19:52.321: E/SoundPool(277): error loading /system/media/audio/ui/Effect_Tick.ogg
    03-29 14:19:52.321: W/AudioService(277): Soundpool could not load file: /system/media/audio/ui/Effect_Tick.ogg
    03-29 14:19:52.330: E/SoundPool(277): error loading /system/media/audio/ui/Effect_Tick.ogg
    03-29 14:19:52.330: W/AudioService(277): Soundpool could not load file: /system/media/audio/ui/Effect_Tick.ogg
    03-29 14:19:52.330: E/SoundPool(277): error loading /system/media/audio/ui/Effect_Tick.ogg
    03-29 14:19:52.330: W/AudioService(277): Soundpool could not load file: /system/media/audio/ui/Effect_Tick.ogg
    03-29 14:19:52.330: E/SoundPool(277): error loading /system/media/audio/ui/Effect_Tick.ogg
    03-29 14:19:52.340: W/AudioService(277): Soundpool could not load file: /system/media/audio/ui/Effect_Tick.ogg
    03-29 14:19:52.340: E/SoundPool(277): error loading /system/media/audio/ui/Effect_Tick.ogg
    03-29 14:19:52.340: W/AudioService(277): Soundpool could not load file: /system/media/audio/ui/Effect_Tick.ogg
    03-29 14:19:52.340: E/SoundPool(277): error loading /system/media/audio/ui/KeypressStandard.ogg
    03-29 14:19:52.370: W/AudioService(277): Soundpool could not load file: /system/media/audio/ui/KeypressStandard.ogg
    03-29 14:19:52.445: E/SoundPool(277): error loading /system/media/audio/ui/KeypressSpacebar.ogg
    03-29 14:19:52.445: W/AudioService(277): Soundpool could not load file: /system/media/audio/ui/KeypressSpacebar.ogg
    03-29 14:19:52.462: E/SoundPool(277): error loading /system/media/audio/ui/KeypressDelete.ogg
    03-29 14:19:52.462: W/AudioService(277): Soundpool could not load file: /system/media/audio/ui/KeypressDelete.ogg
    03-29 14:19:52.491: E/SoundPool(277): error loading /system/media/audio/ui/KeypressReturn.ogg
    03-29 14:19:52.491: W/AudioService(277): Soundpool could not load file: /system/media/audio/ui/KeypressReturn.ogg
    03-29 14:19:52.500: W/AudioService(277): onLoadSoundEffects(), Error -1 while loading samples
    03-29 14:19:56.851: D/skia(1364): --- SkImageDecoder::Factory returned null
    03-29 14:19:56.851: W/dalvikvm(1364): threadid=12: thread exiting with uncaught exception (group=0x41465700)
    03-29 14:19:56.860: E/AndroidRuntime(1364): FATAL EXCEPTION: Thread-121
    03-29 14:19:56.860: E/AndroidRuntime(1364): java.lang.NullPointerException
    03-29 14:19:56.860: E/AndroidRuntime(1364): at com.example.concurrency.MainActivity$1.run(MainAct ivity.java:38)
    03-29 14:19:56.860: E/AndroidRuntime(1364): at java.lang.Thread.run(Thread.java:841)
    03-29 14:19:56.871: W/ActivityManager(277): Force finishing activity com.example.concurrency/.MainActivity
    03-29 14:19:57.381: D/dalvikvm(277): GC_FOR_ALLOC freed 287K, 18% free 6498K/7840K, paused 151ms, total 158ms
    03-29 14:19:57.411: I/WindowManager(277): Screenshot Window{41952188 u0 com.example.concurrency/com.example.concurrency.MainActivity} was all black! mSurfaceLayer=21010 minLayer=21010 maxLayer=21010
    03-29 14:19:58.041: W/EGL_emulation(408): eglSurfaceAttrib not implemented
    03-29 14:19:58.382: D/dalvikvm(408): GC_FOR_ALLOC freed 332K, 13% free 4176K/4796K, paused 150ms, total 159ms
    03-29 14:20:00.151: I/ActivityManager(277): No longer want android.process.acore (pid 1084): empty for 3092s
    03-29 14:20:01.621: I/Process(1364): Sending signal. PID: 1364 SIG: 9
    03-29 14:20:01.631: E/SoundPool(277): error loading /system/media/audio/ui/Effect_Tick.ogg
    03-29 14:20:01.631: W/AudioService(277): Soundpool could not load file: /system/media/audio/ui/Effect_Tick.ogg
    03-29 14:20:01.631: E/SoundPool(277): error loading /system/media/audio/ui/Effect_Tick.ogg
    03-29 14:20:01.631: W/AudioService(277): Soundpool could not load file: /system/media/audio/ui/Effect_Tick.ogg
    03-29 14:20:01.641: E/SoundPool(277): error loading /system/media/audio/ui/Effect_Tick.ogg
    03-29 14:20:01.641: W/AudioService(277): Soundpool could not load file: /system/media/audio/ui/Effect_Tick.ogg
    03-29 14:20:01.641: E/SoundPool(277): error loading /system/media/audio/ui/Effect_Tick.ogg
    03-29 14:20:01.641: W/AudioService(277): Soundpool could not load file: /system/media/audio/ui/Effect_Tick.ogg
    03-29 14:20:01.651: E/SoundPool(277): error loading /system/media/audio/ui/Effect_Tick.ogg
    03-29 14:20:01.662: W/AudioService(277): Soundpool could not load file: /system/media/audio/ui/Effect_Tick.ogg
    03-29 14:20:01.662: E/SoundPool(277): error loading /system/media/audio/ui/KeypressStandard.ogg
    03-29 14:20:01.662: W/AudioService(277): Soundpool could not load file: /system/media/audio/ui/KeypressStandard.ogg
    03-29 14:20:01.691: E/SoundPool(277): error loading /system/media/audio/ui/KeypressSpacebar.ogg
    03-29 14:20:01.691: W/AudioService(277): Soundpool could not load file: /system/media/audio/ui/KeypressSpacebar.ogg
    03-29 14:20:01.711: E/SoundPool(277): error loading /system/media/audio/ui/KeypressDelete.ogg
    03-29 14:20:01.711: W/AudioService(277): Soundpool could not load file: /system/media/audio/ui/KeypressDelete.ogg
    03-29 14:20:01.720: E/SoundPool(277): error loading /system/media/audio/ui/KeypressReturn.ogg
    03-29 14:20:01.730: W/AudioService(277): Soundpool could not load file: /system/media/audio/ui/KeypressReturn.ogg
    03-29 14:20:01.750: W/AudioService(277): onLoadSoundEffects(), Error -1 while loading samples
    03-29 14:20:02.115: I/ActivityManager(277): Process com.example.concurrency (pid 1364) has died.
    03-29 14:21:00.050: W/SystemClock(277): time going backwards: prev 7147403676211(ioctl) vs now 7147400597765(ioctl), tid=306
    03-29 14:25:06.621: I/EventLogService(430): Aggregate from 1396115706202 (log), 1396115706202 (data)
    03-29 14:25:55.193: V/BackupManagerService(277): Running a backup pass
    03-29 14:25:55.201: V/BackupManagerService(277): clearing pending backups
    03-29 14:25:55.201: V/PerformBackupTask(277): Beginning backup of 1 targets
    03-29 14:25:55.230: D/PerformBackupTask(277): invokeAgentForBackup on @pm@
    03-29 14:25:55.354: V/BackupServiceBinder(277): doBackup() invoked
    03-29 14:25:55.390: I/PerformBackupTask(277): no backup data written; not calling transport
    03-29 14:25:55.490: D/PerformBackupTask(277): starting agent for backup of BackupRequest{pkg=android}
    03-29 14:25:55.500: D/BackupManagerService(277): awaiting agent for ApplicationInfo{41761010 android}
    03-29 14:25:55.500: D/BackupManagerService(277): agentConnected pkg=android agent=android.app.backup.BackupAgent$BackupService Binder@41a32608
    03-29 14:25:55.500: I/BackupManagerService(277): got agent android.app.backup.BackupAgent$BackupServiceBinder @41a32608
    03-29 14:25:55.510: D/PerformBackupTask(277): invokeAgentForBackup on android
    03-29 14:25:55.562: V/BackupServiceBinder(277): doBackup() invoked
    03-29 14:25:55.570: D/BackupHelperDispatcher(277): handling existing helper 'wallpaper' android.app.backup.WallpaperBackupHelper@41a965f0
    03-29 14:25:55.604: V/LocalTransport(277): performBackup() pkg=android
    03-29 14:25:55.610: V/LocalTransport(277): Got change set key=wallpaper:/data/system/wallpaper_info.xml size=-1 key64=d2FsbHBhcGVyOi9kYXRhL3N5c3RlbS93YWxscGFwZXJf aW5mby54bWw=
    03-29 14:25:55.650: V/LocalTransport(277): Got change set key=wallpaper:/data/system/wallpaper_info.xml size=113 key64=d2FsbHBhcGVyOi9kYXRhL3N5c3RlbS93YWxscGFwZXJf aW5mby54bWw=
    03-29 14:25:55.671: V/LocalTransport(277): data size 113
    03-29 14:25:55.695: V/LocalTransport(277): finishBackup()
    03-29 14:25:55.750: I/PerformBackupTask(277): Backup pass finished.
    03-29 14:30:00.082: W/SystemClock(277): time going backwards: prev 7687438654956(ioctl) vs now 7687420684236(ioctl), tid=306
    03-29 14:36:01.380: D/dalvikvm(277): GC_FOR_ALLOC freed 1010K, 18% free 6491K/7840K, paused 196ms, total 245ms
    03-29 14:45:10.540: D/GCM(430): Ignoring attempt to send heartbeat on dead connection.
    03-29 14:49:02.530: D/dalvikvm(394): GC_FOR_ALLOC freed 511K, 17% free 3039K/3636K, paused 88ms, total 88ms

  9. #9
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,421
    Rep Power
    25

    Default Re: Threads, loadImageFromNetwork - Unfortunately <application> has stopped

    The only thing I recognize:

    FATAL EXCEPTION: Thread-121
    java.lang.NullPointerException
    at com.example.concurrency.MainActivity$1.run(MainAct ivity.java:38)

    Look at line 38 and find the variable with the null value.
    Zarah likes this.
    If you don't understand my response, don't ignore it, ask a question.

  10. #10
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,014
    Rep Power
    20

    Default Re: Threads, loadImageFromNetwork - Unfortunately <application> has stopped

    If you're doing Android you really need to learn how to read LogCat.
    It's no less important than being able to read stack traces.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  11. #11
    Zarah is offline Senior Member
    Join Date
    Mar 2014
    Posts
    116
    Rep Power
    0

    Default Re: Threads, loadImageFromNetwork - Unfortunately <application> has stopped

    @Norm, Thank you. I could not respond earlier. I had mistakenly deleted my gen/R file and it wouldn't regenerate. I tried to update Eclipse which brought a million errors in every program, I tried to solve it by reinstalling operating system which brought up its own problems.

    So all I remember from this is that ImageView was null, and I had assigned it an object and that had'nt helped. But I'll just resume work and then post a more sensible response.

    @Tolls, Thank you. I think I have never read a stack trace. I am not sound in java either, I am just trying to learn things at the moment.

  12. #12
    Zarah is offline Senior Member
    Join Date
    Mar 2014
    Posts
    116
    Rep Power
    0

    Default Re: Threads, loadImageFromNetwork - Unfortunately <application> has stopped

    @Norm, Thank you for the answer. It was also helpful in learning how to read a LogCat.

    imageView was null. So I defined an ImageView in the layout and assigned it to the imageView by findViewById()

    The application is working now. Following is the code that works fine.

    Java Code:
    package com.example.concurrency;
     
    import java.io.InputStream;
    import java.net.URL;
     
    import android.app.Activity;
    import android.graphics.Bitmap;
    import android.graphics.BitmapFactory;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.ImageView;
     
    public class UsingPostMethod extends Activity {
        
        ImageView imageView;
     
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.using_post_method);
            imageView=(ImageView) findViewById(R.id.imageview);
        }
        
        public void onClick(View v){
        	downloadImage(v);
        }
         
        public void downloadImage(View v){
            new Thread(new Runnable(){
                private Bitmap loadImageFromNetwork(String url){
                    try {
                    Bitmap bitmap = BitmapFactory.decodeStream((InputStream)new URL(url).getContent());
                    return bitmap;
                    } catch (Exception e) {
                    e.printStackTrace();
                    }
                    return null;
                    }
                public void run(){
                    final Bitmap bitmap= loadImageFromNetwork("http://upload.wikimedia.org/wikipedia/commons/7/7a/Basketball.png");
                    imageView.post(new Runnable(){
                        public void run(){
                            imageView.setImageBitmap(bitmap);
                        }
                    });
                }
            }).start();
        }
    }
    Last edited by Zarah; 04-03-2014 at 07:22 PM.

Similar Threads

  1. Unfortunately Application has stopped
    By Sarmad.as in forum Android
    Replies: 3
    Last Post: 03-17-2014, 08:12 PM
  2. The application has stopped responding
    By cdr_nitjsr@yahoo.com in forum Android
    Replies: 3
    Last Post: 07-14-2013, 12:19 AM
  3. unfortunately application has stopped
    By Emmarock in forum Entertainment
    Replies: 3
    Last Post: 07-08-2013, 07:01 PM
  4. Replies: 3
    Last Post: 10-10-2012, 10:06 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •