我查看了此处的示例并尝试复制答案。然而,
Intent callIntent = new Intent(Intent.ACTION_CALL);
什么都不做
Intent callIntent = new Intent(Intent.ACTION_DIAL);
带我到预设号码的数字键盘。
我希望它在不带我到数字键盘的情况下拨打号码。我如何使它工作?
onUpdate():
public void onUpdate(Context context, AppWidgetManager appWidgetManager,
int[] appWidgetIds) {
// TODO Auto-generated method stub
super.onUpdate(context, appWidgetManager, appWidgetIds);
Log.d("HomeWidget", "onUpdate(): ");
for (int appWidgetId : appWidgetIds) {
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:"+12345678));
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, callIntent, 0);
// Get the layout for the App Widget and attach an on-click listener to the button
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_layout);
views.setOnClickPendingIntent(R.id.call, pendingIntent);
// Tell the AppWidgetManager to perform an update on the current App Widget
appWidgetManager.updateAppWidget(appWidgetId, views);
}
}
编辑
从下面的答案中,我看到 Intent.CALL 存在限制,但我真的很想使用它。任何人都可以帮助我如何解除限制?