List of usage examples for android.content Intent getIntent
@Deprecated public static Intent getIntent(String uri) throws URISyntaxException
From source file:cn.jasonlv.siri.activity.MainActivity.java
public void onProcessingResult(ArrayList<String> nbest, String json_res, int fragmentId) { Intent intent = mPackageManager.getInstalledIntentByName(nbest.get(0)); ContactsManager.Contact contact = mContactManager.getContactInfo(nbest); if (null != contact) { Log.e("f**k", contact.name + " : " + contact.number); getFragmentManager().beginTransaction().replace(fragmentId, TextFragment.newInstance(contact.name + "\n" + contact.number + "\n", null)).commit(); }/*from ww w .ja v a 2s .c o m*/ /** * * * * * */ else if (intent != null) { //txtResult.setText("" + nbest.get(0) + "..."); mSynthesizer.speak("" + nbest.get(0)); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } getFragmentManager().beginTransaction() .replace(fragmentId, TextFragment.newInstance("" + nbest.get(0), null)).commit(); startActivity(intent); //txtResult.setText(": " + nbest.get(0)); } else if (nbest.get(0).startsWith("")) { intent = mPackageManager.getInstalledIntentByName(nbest.get(0).substring(4)); if (intent != null) { getFragmentManager().beginTransaction() .replace(fragmentId, TextFragment.newInstance(nbest.get(0).substring(2), null)).commit(); startActivity(intent); } } else if (nbest.get(0).startsWith("")) { intent = mPackageManager.getInstalledIntentByName(nbest.get(0).substring(2)); if (intent != null) { startActivity(intent); } } else if (nbest.get(0).contains("?")) { mSynthesizer.speak("??"); getFragmentManager().beginTransaction() .replace(fragmentId, TextFragment.newInstance("??", null)).commit(); } else if (nbest.get(0).startsWith("")) { if (nbest.get(0).endsWith("?")) { String number = mContactManager .getContactNumber(nbest.get(0).substring(1, nbest.get(0).length() - 3)); if (number != null) { getFragmentManager().beginTransaction() .replace(fragmentId, TextFragment.newInstance("Call: " + number, null)).commit(); Intent i = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + number)); startActivity(i); } else { getFragmentManager().beginTransaction() .replace(fragmentId, TextFragment.newInstance("~", null)).commit(); mSynthesizer.speak(""); } } else if (nbest.get(0).endsWith("?")) { getFragmentManager().beginTransaction().replace(fragmentId, TextFragment.newInstance("", null)) .commit(); } } /** * * * */ else if (SymaticParser.isAlarmEvents(nbest.get(0))) { SymaticParser.extractAlarmEvents(nbest.get(0), getApplicationContext()); } else if (SymaticParser.isAboutTodo(nbest.get(0))) { try { SymaticParser.extractTodoItem(nbest.get(0), getBaseContext()); } catch (ParseException e) { e.printStackTrace(); } } /** * */ else if (nbest.get(0).contains("")) { String songname = musicManager.playRandom(); if (songname != null) { getFragmentManager().beginTransaction() .replace(fragmentId, TextFragment.newInstance(songname, null)).commit(); } } /** * ? * * ?? * ? * * * */ else if (nbest.get(0).endsWith("") && nbest.get(0).startsWith("?")) { String keyword = nbest.get(0).substring(2, nbest.get(0).length() - 3); Intent intent1 = new Intent(this, SimpleImageActivity.class); intent1.putExtra(Constant.Extra.FRAGMENT_INDEX, ImageGridFragment.INDEX); intent1.putExtra("KEYWORD", keyword); startActivity(intent1); } else if (nbest.get(0).endsWith("") && nbest.get(0).startsWith("?")) { String keyword = nbest.get(0).substring(2, nbest.get(0).length() - 2); Intent intent1 = new Intent(this, SimpleImageActivity.class); intent1.putExtra(Constant.Extra.FRAGMENT_INDEX, ImageGridFragment.INDEX); intent1.putExtra("KEYWORD", keyword); startActivity(intent1); } else if (nbest.get(0).endsWith("")) { String keyword = nbest.get(0).substring(0, nbest.get(0).length() - 2); Intent intent1 = new Intent(this, SimpleImageActivity.class); intent1.putExtra(Constant.Extra.FRAGMENT_INDEX, ImageGridFragment.INDEX); intent1.putExtra("KEYWORD", keyword); startActivity(intent1); } /** * * * * * */ else if (nbest.get(0).startsWith("")) { getFragmentManager().beginTransaction().replace(fragmentId, TodoEditorFragment.newInstance("a", "a")) .commit(); } else if (nbest.get(0).startsWith("") || nbest.get(0).contains("")) { Intent in = new Intent(this, TodoActivity.class); startActivity(in); } /** * : * * ? */ else if (SymaticParser.isAboutMapIntent(nbest.get(0))) { ArrayList<String> ends = SymaticParser.extractMapEnds(nbest.get(0)); //APPAndroid, . try { /* "intent://map/direction?origin=latlng:34.264642646862,108.95108518068 |name:&destination=?&mode=driving®ion= &src=yourCompanyName|yourAppName#Intent;scheme=bdapp;package=com.baidu.BaiduMap;end" 45.75 126.63 */ intent = Intent.getIntent("intent://map/direction?origin=latlng:45.75,126.63|name:" + ends.get(0) + "&destination=" + ends.get(1) + "&mode=driving®ion=&src=EDI#Intent;scheme=bdapp;package=com.baidu.BaiduMap;end"); } catch (Exception e) { e.printStackTrace(); Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://api.map.baidu.com/direction?" + "|name:" + ends.get(0) + "&destination=" + ends.get(1) + "&mode=driving&output=html&src=yourCompanyName|yourAppName")); startActivity(browserIntent); } startActivity(intent); //? } /** * . * */ else if (nbest.get(0).contains("")) { getFragmentManager().beginTransaction() .replace(fragmentId, WeatherFragment.newInstance(info.lat, info.lon)).commit(); } else if (nbest.get(0).startsWith("")) { new TranslateGetter().execute(nbest.get(0).substring(2)); } /** * ? * * ? * ?? * ? */ else if (nbest.get(0).endsWith("?")) { getFragmentManager().beginTransaction() .replace(fragmentId, SearchFragment.newInstance(nbest.get(0).substring(0, nbest.get(0).length() - 2))) .commit(); } else if (nbest.get(0).startsWith("?")) { getFragmentManager().beginTransaction() .replace(fragmentId, SearchFragment.newInstance(nbest.get(0).substring(2))).commit(); } /** * ? * * * * ? * ? * * */ else { try { String videoname = null; String bookname = null; String musicname = null; String person = null; videoname = SymaticParser.isMovieInfo(json_res); bookname = SymaticParser.isNovelInfo(json_res); musicname = SymaticParser.isMusicInfo(json_res); person = SymaticParser.isPersonInfo(json_res); if (videoname != null || bookname != null || musicname != null) { getFragmentManager().beginTransaction() .replace(fragmentId, DoubanFragment.newInstance(videoname, musicname, bookname)) .commit(); } else if (person != null) { getFragmentManager().beginTransaction().replace(fragmentId, SearchFragment.newInstance(person)) .replace(fragmentId, SearchFragment.newInstance(person)).commit(); } /** * ?. */ else { new RobotGetter().execute(nbest.get(0)); } } catch (JSONException e) { e.printStackTrace(); ; } } /*else { new WikiGetter().execute(nbest.get(0)); } */ }