bonjour,
je viens de crée un widget(non fonctionnel) cad juste l'interface graphique mais il n'apparait pas dans l'émulteur,sachant qu'il ny a aucun bug. donc si vous pouviez me dire pourquoi... et je soupçonne la faute au niveau de l'androidManifest

MainActivity

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
package com.example.widget;
 
 
import android.appwidget.AppWidgetProvider;
 
public class MainActivity extends AppWidgetProvider{
}
FragmentMain

Code xml : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
   		 android:layout_width="fill_parent"
   		 android:orientation="vertical"
   		 android:layout_gravity="center"
   		 android:layout_height="wrap_content"
   		 android:background="@drawable/heyehy"
   		 >
 
       <TextView
           android:id="@+id/number"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:text="0"
           android:textSize="80sp"
           android:textStyle="bold"
           android:textColor="#FF0000"
 
           />
 
       <ImageButton
           android:id="@+id/boutonplus"
           android:layout_width="92dp"
           android:layout_height="wrap_content"
           android:layout_above="@+id/boutonClear"
           android:layout_alignParentTop="true"
           android:layout_marginLeft="28dp"
           android:layout_toRightOf="@+id/number"
           android:src="@drawable/beer128" />
 
 
       <Button
           android:id="@+id/boutonmoin"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:layout_alignParentLeft="true"
           android:layout_below="@+id/number"
           android:layout_marginTop="16dp"
           android:text="-" 
           />
 
        <Button
            android:id="@+id/boutonClear"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_toRightOf="@id/boutonmoin"
            android:layout_alignTop="@id/boutonmoin"
            android:text="clear"
            android:layout_alignRight="@id/boutonplus"
           />
 
</RelativeLayout>

AndroidManifest



Code xml : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.widget"
    android:versionCode="1"
    android:versionName="1.0" >
 
    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="19" />
 
    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <receiver
            android:name="com.example.widget.MainActivity"
            android:label="@string/app_name"
            android:icon="@drawable/ic_launcher" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
 
                <action android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            <meta-data android:name="android.appwidget.provider"
                android:resource="@xml/my_widget_provider" />
        </receiver>
    </application>
 
</manifest>

MyWidgetProvider



Code xml : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
   android:minWidth="160dip"
   android:minHeight="80dip"
   android:updatePeriodMillis="1000000"
   android:initialLayout="@layout/fragment_main"
 
 
/>