2013-09-29 3 views
0

기본 앱 위젯을 만들려고했는데 위젯 목록에 표시 할 수 없습니다.Android Java 위젯이 위젯 목록에 표시되지 않습니다.

코드는 다음과 같습니다 :

Widget_layout.xml :

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/layout" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:layout_margin="8dip" 
> 

<TextView 
    android:id="@+id/update" 
    style="@android:style/TextAppearance.Medium" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_gravity="center" 
    android:resizeMode="horizontal|vertical" 
    android:gravity="center_horizontal|center_vertical" 
    android:layout_margin="4dip" 
    android:text="@string/click_to_configure" > 
</TextView> 
</LinearLayout> 

Widget_info.xml :

<?xml version="1.0" encoding="utf-8"?> 
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android" 
android:minHeight="72dp" 
android:minWidth="146dp" 
android:updatePeriodMillis="1000" 
android:initialLayout="@layout/widget_layout" 
android:resizeMode="horizontal|vertical" 
android:initialKeyguardLayout="@layout/widget_layout" 
android:widgetCategory="keyguard|home_screen" 
android:configure="com.promethylhosting.countdowntowidget.SettingsActivity" 
/> 

매니페스트 : 나는 주위에 인터넷 검색을 봤는데

<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
package="com.promethylhosting.countdowntowidget" 
android:versionCode="1" 
android:versionName="1.0" > 

<uses-sdk 
    android:minSdkVersion="15" 
    android:targetSdkVersion="17" /> 

<application 
    android:allowBackup="true" 
    android:icon="@drawable/ic_launcher" 
    android:label="@string/app_name" 
    android:theme="@style/AppTheme" > 


<activity 
    android:name=".SettingsActivity" 
    android:icon="@drawable/ic_launcher" 
    android:label="Countdown to... Widget"> 
     <intent-filter> 
      <action android:name=".ACTION_WIDGET_CONFIGURE"/> 

     </intent-filter> 

    <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 
      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
     <!-- mulitple actions must have multiple action filters 1:1 ratio between  action/filter --> 
    </activity> 

    <reciever 
     android:name="CountdownToWidgetProvider" 
     android:icon="@drawable/ic_launcher" 
     android:label="Countdown To Widget"> 
     <intent-filter> 
      <action android:name="android.appwidget.action.APPWIDGET_UPDATE" /> 
     </intent-filter> 
     <meta-data 
      android:name="android.appwidget.provider" 
      android:resource="@xml/widget_info" /> 
    </reciever> 
</application> 
</manifest> 

및 해결책을 찾지 못했습니다. 이 문제가 해결되었습니다. 그래서 나는 여기에 올리고있다.

이 내용과 조언을 읽어 주셔서 감사합니다.

편집 : 다른 제안 사항이 있으십니까?

+0

다른 아이디어를 가지고 4.0

@Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); sendBroadcast(new Intent(Intent.ACTION_MAIN) .addCategory(Intent.CATEGORY_HOME)); setContentView(R.layout.main); } 

의 목록에서 위젯을 표시하는 문제는 항상있다? – mcollard

답변

0

당신의 주요 활동이 시도 또한 참조에게 here

+0

이 코드는 현재 MAIN/LAUNCHER에 있습니다. { sendBroadcast (새 인 텐트 (Intent.ACTION_MAIN) .addCategory (Intent.CATEGORY_HOME))); } catch (Exception e) { \t Log.wtf (LOG_TAG, "위젯을 활성화하려고 시도 중 ... 뭔가 :"+ e.getMessage()); } – mcollard

+0

다른 방법이 있습니까? – mcollard

관련 문제