4
votes

hello I want to change default activity. But when I do that the app doesn't launch at all without any errors

<activity 
        android:name="com.example.dimmer.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>

    <activity
        android:name="com.example.dimmer.DevicesActivity" >
    </activity>

This way MainActivty launches with no proble. It also goes to Device activity when I press the button. So everything works fine. Now I need DevcieACtivty to be default one.

I change Manifest like that

<activity 
            android:name="com.example.dimmer.DevicesActivity"
            android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity
            android:name="com.example.dimmer.MainActivity" >
        </activity>

but now app doesn't launch. no errors. nothing is written in console. it's just doesn't do anything, what might be a problem?

It starts to write the following error ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.dimmer/.MainActivity } [2014-05-16 21:17:10 - Dimmer] ActivityManager: java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.example.dimmer/.MainActivity } from null (pid=13093, uid=2000) requires null

full Manifest

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.dimmer"
    android:versionCode="1"
    android:versionName="1.0" 
    android:hardwareAccelerated="false">

    <uses-sdk
        android:minSdkVersion="9"
        android:targetSdkVersion="14" />
    <uses-permission android:name="android.permission.INTERNET" /> 

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >

        <activity 
            android:name="com.example.dimmer.DevicesActivity"
            android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity
            android:name="com.example.dimmer.MainActivity" >
        </activity>

    </application>

</manifest>


[2014-05-16 22:13:25 - Dimmer] Android Launch!
[2014-05-16 22:13:25 - Dimmer] adb is running normally.
[2014-05-16 22:13:25 - Dimmer] Performing com.example.dimmer.MainActivity activity launch
[2014-05-16 22:13:26 - Dimmer] Uploading Dimmer.apk onto device 'SH17VT514235'
[2014-05-16 22:13:26 - Dimmer] Installing Dimmer.apk...
[2014-05-16 22:13:29 - Dimmer] Success!
[2014-05-16 22:13:29 - Dimmer] Starting activity com.example.dimmer.MainActivity on device SH17VT514235
[2014-05-16 22:13:29 - Dimmer] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.dimmer/.MainActivity }
[2014-05-16 22:13:29 - Dimmer] ActivityManager: java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.example.dimmer/.MainActivity } from null (pid=15458, uid=2000) requires null
5
didn't help. still doesn't launch with DeviceActivity as default oneuser3485986
Are you maybe trying to launch it via a shortcut on your device's homescreen? If so, these shortcuts might contain an old default activity instead of pointing at the new main-activitymarmor
I try to launch it from eclipse. when I launch iut manually from device it worksuser3485986
can you please post your full Android Manifest.. @user3485986Lal
Try deleting the contents of bin folder and run the app..Lal

5 Answers

7
votes

Since you've defined your package as "com.example.dimmer", you can remove package name and use just the name of Activity with dot in front:

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >

    <activity 
        android:name=".DevicesActivity"
        android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <activity
        android:name=".MainActivity" >
    </activity>

</application>

Moreover, check your Run configuration settings in Eclipse. If your launching activity was set to MainActivity, and in manifest you make DevicesActivity as main, your app might not start when launching via Eclipse. Click arrow for RUN icon and choose "Run Configurations",

enter image description here

Then make sure you choose DevicesActivity as Launch:

enter image description here

0
votes

Uninstall the app on your phone, and redownload it.

0
votes

Make sure you implement setContentView in onCreate method.

In other way try clean the project Project > Clean and run it.

0
votes

I am not sure but Now you can some step a head.
such as
1. delete Android.R (in above in your activity )
2. or replace package.R for example , com.example.name.R
3. check you res folder or sub-folder resources .
such as layout attribute right or not.
4. Delete gen and bin folder.
5. clean your project thus: project=>clean
6. restart your eclipse.

Remember that if your resource not found then show this type error.

Best of luck!

0
votes

Click arrow for RUN icon and choose "Run Configurations"
Android Application =>select project
open Target tab
select Always prompt to divice
click run and select Divice online