简体   繁体   English

找不到Android Widget启动器活动

[英]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 我是Android SDK的新手,但是我对JAVA有点了解。我使用的是SDK v4。问题是,我试图制作“ HelloWidget”主屏幕小部件(仅带有文本框),并且尝试运行项目,控制台给了我

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: 我的应用程序在AVD中找不到了。我曾尝试将.MAIN和Launcher放入Intent过滤器中,但效果不佳。以下是我的文件:

AndroidManifest.xml 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 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 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 Java文件

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 我从这里遵循了该教程: 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. 不能使用MAIN操作启动应用程序小部件,只能使用活动来启动。 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. 您的应用小部件现在将显示在主屏幕上。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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