AndroidManifest.xml - intent-filter에 해당 액션을 정의 해준다.
<intent-filter>
<action android:name="jh.project.widget.digital.third.action.CLICK" />
</intent-filter>
source.java (AppWidgetProvider 에서 돌릴 service) - Remoteview에 onClick시 Pending Intent를 정의하고, onStart에 구현한다.
static final String ACTION_CLICK = "jh.project.widget.digital.third.action.CLICK";
public void onCreate() {
RemoteViews views = new RemoteViews(getPackageName(), R.layout.main);
Intent newIntent = new Intent();
newIntent.setAction(ACTION_CLICK);
PendingIntent pIntent = PendingIntent.getService(this, 0, newIntent, 0);
views.setOnClickPendingIntent(R.id.imgin /*(event를 적용할 componet - e.g. ImageView)*/, pIntent);
}
public void onStart(Intent intent, int startId) {
super.onStart(intent, startId);
if (ACTION_CLICK.equals(intent.getAction())) {
updateWidget();
}
}
맞나?? ㅋㅋ
댓글 없음:
댓글 쓰기