4

I've a problem developing an application, I'm building a Widget that can be either on lockscreen or in home page. when is in lockscreen I want that when the user clicks a button the widget prompt for the user login in case of needed. I mean prompt for patter or password or face recognition depending if the user have any of this security enabled. after the user enter his pattern the widget will run an application (intent).

I've notice that some widgets does prompt for login and other doesn't I haven't found the difference between them.

I think this has to be on the onReceive method but not sure how can I call this "login" method, so far on the onReceive I start the intent

i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
i.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);    
context.getApplicationContext().startActivity(i);

but this still not prompt for login. when the widget is on the lockscreen.

let say that the user interacts with the widget in the Lock screen, the user is not prompted to enter the password, either way the user does enter his pattern|password and after the user "enter" his home screen and the application is started. So the widget does start the intent just don't let the user "know" or login to see the application.

any thoughts on how can I prompt the user to enter his pattern so it enter to the home screen?

[Edit]

The problem occurs when I try to fire the intent within a BroadcastReceiver. What I do is allow the user interact with the widgetd buttons, depending on what the user has selected I'll open my application adding some extras to the intent.

so on the onReceive method of my BroadcastReceiver I try to fire:

Intent i = new Intent(context, MyActivity.class);
i.putExtra(WidgetUtils.TAG_CURRENT_SELECTION, StringIGotFromInteraction);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.getApplicationContext().startActivity(i);

this way the intent don't prompt for the "unblock".

If in the onUpdate I cast the pending intent to any button when the user clicks that button does prompt for the unlock this way:

views.setOnClickPendingIntent(R.id.aButton, buildAPendingIntent(context)); 

but I need to know what has the user selected to open and Intent in case I open any.

and my contex.startActivity Approach works fine when the widget is on home screen just not on loockscreen.

Any thoughts how can I make this happen.

4

1 回答 1

0

我找不到答案,我最终要做的是创建一个动态按钮,当小部件更新时(通过其他按钮),我将 PendingIntent 分配给这个按钮。

因此,当用户单击此动态按钮时,小部件会尝试打开意图,并在提示用户输入密码时出现。

我认为这不是我们让用户额外点击小部件的最佳解决方案。

于 2013-07-11T22:59:13.483 回答