到目前为止,我有以下代码:
// Login Button
Intent loginIntent = new Intent(this.getApplicationContext(), LoginActivity.class);
loginIntent.putExtra("Source", "widgetLogin");
PendingIntent loginPIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, loginIntent, Intent.FLAG_ACTIVITY_NEW_TASK);
returnView.setOnClickPendingIntent(R.id.widget_login_button_login, loginPIntent);
return returnView;
但是当我点击它时没有任何反应?我确信我只是错过了我的意图。
答案 0 :(得分:3)
更改
PendingIntent.getBroadcast(getApplicationContext(), 0, loginIntent, Intent.FLAG_ACTIVITY_NEW_TASK)
到
PendingIntent.getActivity(getApplicationContext(), 0, loginIntent, Intent.FLAG_ACTIVITY_NEW_TASK);