2012-03-09 35 views
2

我是新來的Android SDK,但我知道JAVA有點。我在SDK V4。問題是,我試圖使'HelloWidget'主屏幕小部件(只有一個文本框),當我嘗試運行該項目,控制檯給我Android Widget Launcher活動找不到

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

而且我的應用程序是無處在AVD.I被發現曾試圖把。主要和啓動的意圖過濾器,但沒有好。這裏是我的文件:

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文件

package ax.startup; 
import android.appwidget.AppWidgetProvider; 
public class AxStartup extends AppWidgetProvider { 
} 

我跟着從這裏教程: http://www.helloandroid.com/files/xmaswidget/android_howto-hellowidget.pdf

而另一個奇怪的問題是,當我長時間按下d esktop,只有改變壁紙的選項即將到來。沒有「添加到主屏幕」或「小工具」或任何其他菜單! 請告訴我什麼是問題。

回答

1

應用程序小部件無法使用MAIN操作啓動,僅限於活動。另外,如果您的應用只有應用小部件,您將看不到應用圖標。日誌消息說應用程序已部署到模擬器,但您必須手動啓動應用程序窗口小部件。

轉到設備上的主屏幕並在屏幕上長按。你會得到一個菜單來添加一個元素到主屏幕。其中一個選項是「Widgets」。選擇它並導航到您的應用程序小部件。您的應用程序小部件現在將在主屏幕上。

+0

我試過了,但是當我在主屏幕上長時間按下時,我所得到的只是更換壁紙(動態壁紙,壁紙庫等)。我正在使用Android SDK 4.我如何部署小部件使用活動? – dil33pm 2012-03-09 11:42:27