[英]How to add an activity to a widget
我創建了一個小窗口小部件應用程序。 昨天,我決定為該程序添加更多功能,因此我需要進行一次活動,因為該小部件看起來不錯,但是我想在我的應用中為用戶提供更多信息(列表視圖,我所需要的按鈕)。 因此,在/ layout文件夾中,我為活動的圖形設計創建了一個“ config.xml”。 它只有一個textview,不需要編碼。
然后,我創建了MainActivity.java,看起來很簡單:
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.config);
TextView txt = (TextView) findViewById(R.id.TextView01);
txt.setText("Something");
}
}
AndroidManifest.xml:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.bfarago.hellowidget"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<receiver android:name=".HelloWidget" android:label="@string/app_name">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data android:name="android.appwidget.provider" android:resource="@xml/hello_widget_provider" />
</receiver>
<service android:enabled="true" android:name=".UpdateService" />
<activity android:name=".MainActivity"
android:label="@string/hello">
<intent_filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent_filter>
</activity>
</application>
問題是,當我啟動該應用程序時,在其他應用程序中看不到它的圖標。 我想念什么?
AndroidManifest.xml指定應在應用程序網格中顯示默認的“ Droid”圖標-默認名稱(來自res / values / strings.xml )為“ User Application ”。 有嗎
“啟動應用程序”是指小部件還是活動? 當然,活動通常會顯示並隱藏其他任何圖標或應用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.