2
我已閱讀此thread和其他一些在計算器上,但我的問題似乎還沒有解決。Android中沒有顯示的小工具> 4.2.2
下面是從我的代碼片斷:(清單file.xml)
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.eightbitcloud.example.widget"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="4"
android:targetSdkVersion="11" />
<application
android:icon="@drawable/icon"
android:label="@string/app_name" >
<activity
android:name=".WidgetExampleActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="com.eightbitcloud.example.widget.ACTION_WIDGET_CONFIGURE" />
</intent-filter>
</activity>
<receiver
android:name=".ExampleAppWidgetProvider"
android:label="@string/widget1name" >
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
<action android:name="com.eightbitcloud.example.widget.ACTION_WIDGET_RECEIVER" />
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="@xml/widget1_info" />
</receiver>
</application>
</manifest>
和也:MainActivity.java作爲WidgetExampleActivity.java
public class WidgetExampleActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
sendBroadcast(new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME));
setContentView(R.layout.main);
}
}
和/ RES/XML/widget_info .xml
<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:minWidth="294dp"
android:minHeight="72dp"
android:updatePeriodMillis="10000"
android:initialLayout="@layout/widget1"
>
</appwidget-provider>
問題是該小部件出現在Android版本< = 4.1但它並不出現在我的android> = 4.2上。我知道這是因爲我在不同的設備上測試過它。請,我該如何解決這個問題。
仍然獲得了Android OS目標的休息不工作 –