0

I am trying to learn and test the log files. Below is my codes. How to overcome this issue?

   public class MainActivity extends ActionBarActivity {

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            final String hello=getResources().getString(R.string.hello_world);
            final String STRING_TAG = "Testing: ";
            Log.i(STRING_TAG," String1 " + hello);


            if (savedInstanceState == null) {
                getSupportFragmentManager().beginTransaction()
                        .add(R.id.container, new PlaceholderFragment())
                        .commit();
            }
        }


        @Override
        public boolean onCreateOptionsMenu(Menu menu) {

            // Inflate the menu; this adds items to the action bar if it is present.
            getMenuInflater().inflate(R.menu.main, menu);
            return true;
        }

        @Override
        public boolean onOptionsItemSelected(MenuItem item) {
            // Handle action bar item clicks here. The action bar will
            // automatically handle clicks on the Home/Up button, so long
            // as you specify a parent activity in AndroidManifest.xml.
            int id = item.getItemId();
            if (id == R.id.action_settings) {
                return true;
            }
            return super.onOptionsItemSelected(item);
        }

        /**
         * A placeholder fragment containing a simple view.
         */
        public static class PlaceholderFragment extends Fragment {

            public PlaceholderFragment() {
            }

            @Override
            public View onCreateView(LayoutInflater inflater, ViewGroup container,
                    Bundle savedInstanceState) {
                View rootView = inflater.inflate(R.layout.fragment_main, container, false);
                return rootView;
            }
        }

    }

I get the following errors.

[2014-06-09 00:09:48 - test1] Android Launch!
[2014-06-09 00:09:48 - test1] adb is running normally.
[2014-06-09 00:09:48 - test1] Performing com.example.test1.MainActivity activity launch
[2014-06-09 00:09:48 - test1] Automatic Target Mode: using existing emulator 'emulator-5554' running compatible AVD 't1'
[2014-06-09 00:09:52 - test1] Application already deployed. No need to reinstall.
[2014-06-09 00:09:52 - test1] Starting activity com.example.test1.MainActivity on device emulator-5554
[2014-06-09 00:09:55 - test1] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.test1/.MainActivity }
[2014-06-09 00:09:55 - test1] ActivityManager: Warning: Activity not started, its current task has been brought to the front
[2014-06-09 00:11:45 - test1] Dx 
Manishika
  • 5,478
  • 2
  • 22
  • 28
user2711681
  • 285
  • 7
  • 16

2 Answers2

3

Log in code goes to the logcat by default

The output you posted is not the logcat but the IDE console (and there are no errors - just usual messages seen when launching an app)

Click on the "Logcat" tab to see device-side logs.

laalto
  • 150,114
  • 66
  • 286
  • 303
  • I get this in red test1] ActivityManager: Warning: Activity not started, its current task has been brought to the front [2014-06-09 00:11:45 - test1] Dx. So what should I do my app does not run ? – user2711681 Jun 08 '14 at 18:13
  • 1
    Up-to-date version of your app was already running in the device and it was just brought to foreground. Usually you launch your code for testing after modifying it which kills the existing app (when installing the newer version). If you want to explicitly rerun `onCreate()`, you can terminate the app in the app manager of the device. – laalto Jun 08 '14 at 18:16
  • Sorry I am a bit lost now. I have close the code and run again but it does not appear now. So what cause it to go into foreground is the log.i ? – user2711681 Jun 08 '14 at 18:19
  • if logcat is not showing any line restarting eclipse is maybe not enough. i have success with the following steps: 1) terminate eclipse 2) kill the running process adb 3) start eclipse ( before I try the "Reset adb" button in the DDMS view. this helps some times ) to restart the emulator is not necessary. about slow emulator: look at this thread –  Jun 08 '14 at 20:59
  • if it does not open by itself, press the logcat button. if you don't have the logcat button go to -> Window -> Show View -> Other ... -> Android -> LogCat –  Jun 08 '14 at 21:04
  • sorry didn't paste the url for my posting above about performance. here the [link](http://stackoverflow.com/questions/1554099/why-is-the-android-emulator-so-slow) –  Jun 08 '14 at 21:08
1

These are not the errors, rather it is the Console log which shows message related to app launch.

`Warning: Activity not started, its current task has been brought to the front`

For resolving this you have to close the app manually in emulator/phone.

Generally this warning is generated the the user doesn't make any changes in the code & re-run it again.

For resolving this either close the app manually in emulator/phone or modify some code.

UPDATE:

If your logcat does not display even a single line then Restart Eclipse.

Vivek Warde
  • 1,936
  • 8
  • 47
  • 77
  • I get this in red test1] ActivityManager: Warning: Activity not started, its current task has been brought to the front [2014-06-09 00:11:45 - test1] Dx. So what should I do my app does not run ? – user2711681 Jun 08 '14 at 18:13
  • Ok what should I do close the emulator ? – user2711681 Jun 08 '14 at 18:16
  • No need to restart the emulator ! either close the app manually in emulator/phone or modify some of ur code – Vivek Warde Jun 08 '14 at 18:18
  • I close my app and and tried to rerun my codes nothing is shown up now. – user2711681 Jun 08 '14 at 18:21
  • You are seeing this message in console tab, open **logcat** tab – Vivek Warde Jun 08 '14 at 18:23
  • Nope I dont see anything in the logcat tab and it stop here for the console [2014-06-09 02:23:17 - test1] ActivityManager: Warning: Activity not started, its current task has been brought to the front this message is in red and maybe I am putting the log at the wrong place ? – user2711681 Jun 08 '14 at 18:24
  • Try using `Log.v(STRING_TAG," String1 " + hello);` – Vivek Warde Jun 08 '14 at 18:26
  • perhaps You mean to say logcat does not display even a single line? – Vivek Warde Jun 08 '14 at 18:26
  • Yes it does not display even a single line. Could it be I am putting the log at the wrong place? How to manually close it by pressing my home button it get to the home and close the app ? – user2711681 Jun 08 '14 at 18:28
  • Ok but I go to restart with the emulator it take a long time. What emulator you recommend. I tried now Log.v(STRING_TAG," String1 " + hello); also same. Ok I am going to restart and update you. – user2711681 Jun 08 '14 at 18:30
  • Restart **Android Eclipse IDE** not emulator – Vivek Warde Jun 08 '14 at 18:33
  • Sorry I am very new I restart the whole of the eclipse and how to just restart Android Eclipse IDE alone ? – user2711681 Jun 08 '14 at 18:35
  • You not need to be confused,It is the same thing I just overwritten the name of eclipse – Vivek Warde Jun 08 '14 at 18:37
  • Ok I found it is in the File -> Restart. Ok now my question the log.v or log.i am I putting at the right place or wrong place. Should be position else where for it to work and appear properly. I am just doing some test on how the log will appear. – user2711681 Jun 08 '14 at 18:38
  • It is the right place ! see this http://stackoverflow.com/questions/7959263/android-log-v-log-d-log-i-log-w-log-e-when-to-use-each-one – Vivek Warde Jun 08 '14 at 18:40
  • Thank you for the link so meaning I can log any place I wish to. – user2711681 Jun 08 '14 at 18:43
  • Ok what emulator you suggest best and fast cause I notice most of it takes like at least 10 minutes to start ? – user2711681 Jun 08 '14 at 18:49
  • http://stackoverflow.com/questions/14539730/increasing-the-android-sdk-emulator-speed see this – Vivek Warde Jun 08 '14 at 18:53