简体   繁体   English

小部件未显示android

[英]Widget not showing up android

I am trying to create a widget for my application, I implemented widget using 我正在尝试为我的应用程序创建一个小部件,我使用

File->New->widget->Appwidget

all the corresponding code was auto-generated, but when I run my app, the widget is not shown, can anyone help me on how do I show the widget on my home screen. 所有相应的代码都是自动生成的,但是当我运行我的应用程序时,未显示该小部件,任何人都可以帮助我如何在主屏幕上显示该小部件。

my manifest file 我的清单文件

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.work.income">

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

<!-- To auto-complete the email text field in the login form with the user's emails -->
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.READ_PROFILE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />

<application
    android:name=".MyApplication"
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:installLocation="preferExternal"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".LoginActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name=".AddExpenseActivity" />
    <activity android:name=".AddIncomeActivity" />
    <activity
        android:name=".MainActivity"
        android:label="@string/title_activity_login" />

    <receiver android:name=".NewAppWidget"
      >
        <intent-filter>
            <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
        </intent-filter>

        <meta-data
            android:name="android.appwidget.provider"

            android:resource="@xml/new_app_widget_info" />
    </receiver>
</application>

</manifest>

hi please check that code 嗨,请检查该代码

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
   package="com.example.sairamkrishna.myapplication" >

   <application
      android:allowBackup="true"
      android:icon="@mipmap/ic_launcher"
      android:label="@string/app_name"
      android:theme="@style/AppTheme" >
      <receiver android:name=".MainActivity">

      <intent-filter>
         <action android:name="android.appwidget.action.APPWIDGET_UPDATE"></action>
      </intent-filter>

      <meta-data android:name="android.appwidget.provider"
         android:resource="@xml/mywidget"></meta-data>

      </receiver>

   </application>
</manifest>

In your code there is one default launcher but when you create a widget no need to launcher 在您的代码中,有一个默认的启动器,但是在创建小部件时无需启动器

The code is working fine. 该代码工作正常。

The thing that helped me was rebooting my phone, after that the widget started appearing in the widget list. 在小部件列表中开始显示小部件之后,帮助我的是重新启动手机。

refer Widget not showing in widget list 请参阅小部件列表中未显示的小部件

refer this to get widget on the homescreen How to add a widget to the Android home screen from my app? 请参阅此以在主屏幕上获取小部件。 如何从我的应用程序向Android主屏幕添加小部件?

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

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