简体   繁体   中英

Android Widget Launcher Activity not found

I am new to Android SDK,but I know JAVA a little.I am on SDK v4.The problem is that,I tried to make 'HelloWidget' Home Screen Widget (with just a text box),and when I try to run the project,the console gives me

No Launcher Activity Found!
The application will only sync the package to the device!

And my app is nowhere to be found in the AVD.I had tried putting the .MAIN and Launcher in Intent filter,but no good.Here are my files:

AndroidManifest.xml

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

    <uses-sdk android:minSdkVersion="15" />

    <uses-permission android:name="android.permission.INTERNET"/>

    <application 
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >

        <!-- Broadcast Receiver that will process AppWidget updates -->
        <receiver android:name=".AxStartup" android:label="AxStartup">
            <intent-filter>
                <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
                <action android:name="android.intent.action.MAIN"  />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>

            <meta-data android:name="android.appwidget.provider"
                android:resource="@layout/startup_info" />
        </receiver>
    </application>
</manifest>

main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <EditText
        android:id="@+id/txt1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="HELLO WORLD" />

</LinearLayout>

startup_info.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <EditText
        android:id="@+id/txt1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:inputType="textMultiLine" 
        android:text="ITS WORKING DUDE!"
        android:minWidth="146dip"
        android:minHeight="72dip"
        android:updatePeriodMillis="10000"
        android:initialLayout="@layout/startup_info">
    <requestFocus />
    </EditText>
</LinearLayout>

Java file

package ax.startup;

import android.appwidget.AppWidgetProvider;

public class AxStartup extends AppWidgetProvider {
}

I followed the tutorial from here: http://www.helloandroid.com/files/xmaswidget/android_howto-hellowidget.pdf

And another strange problem is that when I long press on desktop,only options to change wallpaper is coming.There is no 'Add to Home Screen' or 'Widgets' or any other menu!!! Please tell me what is the problem.

An application widget can not be launched with a MAIN action, only activities. Also, if your app only has an application widget you will not see an app icon. The log messages are saying that the app was deployed to the emulator but you must start the app widget manually.

Go to the home screen on the device and do a long-press on the screen. You will get a menu to add an element to the home screen. One of the options will be "Widgets". Select that and navigate to your app widget. Your app widget will now be on the home screen.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM