android ACTION_WEB_search无效

时间:2011-12-30 13:57:24

标签: android

我无法让ACTION_WEB_SEARCH正常工作,这是否需要AndriodManifest.xml的任何权限?

其他ACTIONS工作(电子邮件,电话,短信)。还有如何进行地图搜索? 使用什么动作是否有action_searchmap? 这是我尝试去网址时得到的错误

            12-30 15:34:33.798: E/AndroidRuntime(4972): FATAL EXCEPTION: main
                       12-30 15:34:33.798: E/AndroidRuntime(4972): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=url:http://www.google.com }
                        12-30 15:34:33.798: E/AndroidRuntime(4972):     at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1408)
                        12-30 15:34:33.798: E/AndroidRuntime(4972):     at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378)
                          12-30 15:34:33.798: E/AndroidRuntime(4972):   at android.app.Activity.startActivityForResult(Activity.java:2817)
                        12-30 15:34:33.798: E/AndroidRuntime(4972):     at android.app.Activity.startActivity(Activity.java:2923)
                          12-30 15:34:33.798: E/AndroidRuntime(4972):   at org.example.dbcontactconsole.Detalii.onListItemClick(Detalii.java:91)
                        12-30 15:34:33.798: E/AndroidRuntime(4972):     at android.app.ListActivity$2.onItemClick(ListActivity.java:321)
                       12-30 15:34:33.798: E/AndroidRuntime(4972):  at android.widget.AdapterView.performItemClick(AdapterView.java:284)
                        12-30 15:34:33.798: E/AndroidRuntime(4972):     at android.widget.ListView.performItemClick(ListView.java:3382)
                         12-30 15:34:33.798: E/AndroidRuntime(4972):    at android.widget.AbsListView$PerformClick.run(AbsListView.java:1696)
                         12-30 15:34:33.798: E/AndroidRuntime(4972):    at android.os.Handler.handleCallback(Handler.java:587)
                        12-30 15:34:33.798: E/AndroidRuntime(4972):     at android.os.Handler.dispatchMessage(Handler.java:92)
                         12-30 15:34:33.798: E/AndroidRuntime(4972):    at android.os.Looper.loop(Looper.java:123)
                              12-30 15:34:33.798: E/AndroidRuntime(4972):   at android.app.ActivityThread.main(ActivityThread.java:4627)
                            12-30 15:34:33.798: E/AndroidRuntime(4972):     at java.lang.reflect.Method.invokeNative(Native Method)
                            12-30 15:34:33.798: E/AndroidRuntime(4972):     at java.lang.reflect.Method.invoke(Method.java:521)
             12-30 15:34:33.798: E/AndroidRuntime(4972):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
             12-30 15:34:33.798: E/AndroidRuntime(4972):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
             12-30 15:34:33.798: E/AndroidRuntime(4972):    at dalvik.system.NativeStart.main(Native Method)

我的java代码是: `               if(cursor.getCount()== 1)            {         cursor.moveToFirst();

   actiune= new ArrayList<Actiune>();
   String phoneString=cursor.getString(cursor.getColumnIndex("phone"));
   if (phoneString!=null)
   {
    actiune.add(new Actiune("Suna la numar",phoneString,Actiune.ACTION_CALL));
    actiune.add(new Actiune("SMS",phoneString,Actiune.ACTION_SMS));
   }
   String stringemail = cursor.getString(cursor.getColumnIndex("email"));
   if (stringemail != null) {
           actiune.add(new Actiune("Email", stringemail,Actiune.ACTION_EMAIL));
           }
   adapter = new ActiuneAdapter();
   setListAdapter(adapter);
   String stringurl = cursor.getString(cursor.getColumnIndex("url"));
   if (stringurl != null) {
           actiune.add(new Actiune("ADRESA URL", stringurl,Actiune.ACTION_VIEW));
           }
   adapter = new ActiuneAdapter();
   setListAdapter(adapter);
           }
           }
            public void onListItemClick(ListView parent, View view, int position, long id) {

Actiune action = actiune.get(position);

Intent intent;
switch (action.getType()) {

    case Actiune.ACTION_CALL:  
            Uri callUri = Uri.parse("tel:" + action.getData());  
            intent = new Intent(Intent.ACTION_CALL, callUri);
        startActivity(intent);
            break;

    case Actiune.ACTION_EMAIL:  
    intent = new Intent(Intent.ACTION_SEND);
    intent.setType("plain/text");
    intent.putExtra(Intent.EXTRA_EMAIL, new String[]{action.getData()});
    startActivity(intent);
    break;
    case Actiune.ACTION_SMS:  
        Uri smsUri = Uri.parse("sms:" + action.getData());  
        intent = new Intent(Intent.ACTION_VIEW, smsUri); 
        startActivity(intent);
        break;
    case Actiune.ACTION_VIEW:
        Uri adressuri=Uri.parse("url:"+action.getData());
    intent = new Intent(Intent.ACTION_VIEW,adressuri);
                startActivity(intent);
       }
         }    

`

1 个答案:

答案 0 :(得分:0)

ACTION_VIEW案例中,从uri中删除url:

Uri adressuri = Uri.parse(action.getData());