简体   繁体   中英

How to add an activity to a widget

i created a small widget app. Yesterday i decided add more functionality to the program, so i need an activity, because the widget looks good but i want to serve more information in my app for the users (listview, buttons that's what i need). So in the /layout folder i created a "config.xml" for the graphical design of the activity. This has only a textview, no need for coding.

Then i created the MainActivity.java, which looks easy as hell:

    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>

Problem is, when i launch the app I cannot see it's icon among the other application. What do i miss?

The AndroidManifest.xml specifies that the default "Droid" icon should appear in the apps grid - the default name (from res/values/strings.xml ) is " User Application ". Is it there?

By "launch the app" do you mean the widget or the activity? An activity, of course, normally takes the display and hides any other icons or apps.

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