2014-12-05 30 views
0

我在嘗試通過單擊textview時啓動活動時收到異常。 這裏是我的代碼用於訪問活動使用Linkify訪問活動時出現異常

tv1.setText(result+" "); 
       tv1.setEms(5); 
       Pattern pattern = Pattern.compile("[a-zA-Z/a-zA-Z]"); 
       Linkify.addLinks(tv1, pattern,null); 
       tv1.setOnClickListener(new OnClickListener() { 

        public void onClick(View v) { 
         Intent ourIntent = new Intent(Http_schedule.this, HttpSecondSchedule.class);      
         try { 
          ourIntent.putExtra("Voyage", (String)jo.get("Voyage")); 
          ourIntent.putExtra("Ship", jo.get("Ship").toString()); 
          startActivity(ourIntent); 
         } catch (JSONException e) { 
          // TODO Auto-generated catch block 
          e.printStackTrace(); 
         } 
        } 
       }); 
       tbrow2.addView(tv1); 

這裏是我註冊了我的第二個活動

<activity 
     android:name=".HttpSecondSchedule" 
     android:label="Seat Availability" 
     android:screenOrientation="portrait" 
     android:configChanges="keyboardHidden|orientation|screenSize" 
     > 
     <intent-filter> 
      <action android:name="com.example.ship_service_list.HttpSecondSchedule" /> 

      <category android:name="android.intent.category.DEFAULT" /> 
     </intent-filter> 
    </activity> 

這裏android.manifest文件被錯誤我得到

12-05 08:16:38.600: E/InputEventReceiver(1458): Exception dispatching input event. 
12-05 08:16:38.600: E/MessageQueue-JNI(1458): Exception in MessageQueue callback: handleReceiveCallback 
12-05 08:16:38.770: E/MessageQueue-JNI(1458): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=v (has extras) } 
12-05 08:16:38.770: E/MessageQueue-JNI(1458): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1632) 
12-05 08:16:38.770: E/MessageQueue-JNI(1458): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1424) 

]

+0

您使用'NDK'?錯誤似乎來自'JNI' – 2014-12-05 13:37:22

+0

我沒有使用ndk – 2014-12-06 05:50:04

+0

Pattern pattern = Pattern.compile(「[a-zA-Z/a-zA-Z]」); \t \t \t \t \t //Linkify.addLinks(tv1,pattern,null);我這樣做了,錯誤消失了......是否有任何替代方案。 – 2014-12-06 06:08:59

回答

0
Intent ourIntent = new Intent(Http_schedule.this, HttpSecondSchedule.class);      
     try { 
      ourIntent.setAction("com.example.ship_service_list.HttpSecondSchedule"); 
       ourIntent.putExtra("Voyage", (String)jo.get("Voyage")); 
       ourIntent.putExtra("Ship", jo.get("Ship").toString()); 
       startActivity(ourIntent); 
     } catch (JSONException e) { 
       // TODO Auto-generated catch block 
       e.printStackTrace(); 
     } 
+0

它不工作的朋友.. – 2014-12-06 05:48:22

0

您需要爲此擁有兩個元素。其中一個 將用於MAIN和LAUNCHER。其他將是VIEW, BROWSABLE/DEFAULT,和你的元素:

<activity android:name=".MyActivity"> <intent-filter>` <action android:name="android.intent.action.MAIN"></action> <category android:name="android.intent.category.LAUNCHER"></category> </intent-filter> <intent-filter> <action android:name="android.intent.action.VIEW"></action> <category android:name="android.intent.category.DEFAULT"></category> <category android:name="android.intent.category.BROWSABLE"></category> <data android:host="my.app" android:scheme="http"></data> </intent-filter> </activity>

然後,http://my.app應該啓動你的活動。

- https://stackoverflow.com/a/7417688/1815624

相關問題