关于android删除语音搜索功能的基本操作方法

       最近在调试android 4.1系统的平板,发现在进行录音操作的时候,系统总是频繁的自动弹出语音搜索对话框,而且需要连续关闭好几次才能把它关闭掉,也不知道这到底是怎么回事,估计可能是系统还不太稳定的缘故吧。没办法,最后就想到干脆把语音搜索的程序删除算了,反正这个语音搜索也是不太好使。好了,下面来说一说这个具体的操作流程,

1.删除系统自带的语音搜索程序

.      android 源代码里好像没有语音搜索的源代码,只找到它的apk文件,而且语音搜素与谷歌搜素是连在一起的,要删除语音搜索的话,还必须同时删除了谷歌搜素程序,需要删除的apk文件有device/.../googleapps/app/目录下的velvet.apk以及VoiceSearchStub.apk,同时还需要删除out目录下对应的APK文件,然后就可以编译生成固件,对机器进行升级了。

2.删除浏览器自带的语音搜索功能

       要删除浏览器网址输入框右边的语音搜素按钮(麦克风图标),只需在packages/apps/Browser/src/com/android/browser/NavigationBarTablet.java文件里注释掉下面这行代码应该就行了:
       //mVoiceButton.setVisibility(View.VISIBLE);
3.经过第一步操作后,发现在窗口小部件中,长按住搜素控件,概率性弹出搜索出错对话框,而且点击搜索控件中的文字区域,不能进入搜索程序。

     3.1 解决长按搜索控件异常出错且不能进入搜素程序的问题
diff --git a/packages/apps/QuickSearchBox/src/com/android/quicksearchbox/SearchWidgetProvider.java b/packages/apps/QuickSearchBox
index 2c947e6..0793cf9 100755
--- a/packages/apps/QuickSearchBox/src/com/android/quicksearchbox/SearchWidgetProvider.java
+++ b/packages/apps/QuickSearchBox/src/com/android/quicksearchbox/SearchWidgetProvider.java
@@ -185,8 +185,18 @@ public class SearchWidgetProvider extends BroadcastReceiver {
 
         private void setOnClickActivityIntent(Context context, RemoteViews views, int viewId,
                 Intent intent) {
-            PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
-            views.setOnClickPendingIntent(viewId, pendingIntent);
+              
+            //Log.e("TTTT","///////////////////////////");
+            /**add try...catch...to get the exception by gst 2012/10/15,otherwise,the text field of widget could not be clicked*/
+            try{
+                PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
+               views.setOnClickPendingIntent(viewId, pendingIntent);
+              
+            }catch(Exception e){
+               e.printStackTrace();
+            }
+              
+          

 

    3.2 删除窗口小部件中搜索栏中的语音搜索按钮,注意,下面是layout-xlarge目录下的search_widget.xml文件,而不是layout目录下的search_widget.xml

diff --git a/packages/apps/QuickSearchBox/res/layout-xlarge/search_widget.xml b/packages/apps/QuickSearchBox/res/layout-xlarge/se
index dcd81ff..630808a 100755
--- a/packages/apps/QuickSearchBox/res/layout-xlarge/search_widget.xml
+++ b/packages/apps/QuickSearchBox/res/layout-xlarge/search_widget.xml
@@ -68,7 +68,7 @@
                     />
 
                
+
            

 
diff --git a/packages/apps/QuickSearchBox/src/com/android/quicksearchbox/SearchWidgetProvider.java b/packages/apps/QuickSearchBox
index 60d82a2..2c947e6 100755
--- a/packages/apps/QuickSearchBox/src/com/android/quicksearchbox/SearchWidgetProvider.java
+++ b/packages/apps/QuickSearchBox/src/com/android/quicksearchbox/SearchWidgetProvider.java
@@ -169,14 +169,17 @@ public class SearchWidgetProvider extends BroadcastReceiver {
             setOnClickActivityIntent(context, views, R.id.search_widget_text,
                     mQueryTextViewIntent);
             // Voice Search button
+/**del the voice search button by gst
             if (mVoiceSearchIntent != null) {
                 setOnClickActivityIntent(context, views, R.id.search_widget_voice_btn,
                         mVoiceSearchIntent);
                 views.setViewVisibility(R.id.search_widget_voice_btn, View.VISIBLE);
             } else {
                 views.setViewVisibility(R.id.search_widget_voice_btn, View.GONE);
             }
       
+*/
             appWidgetMgr.updateAppWidget(mAppWidgetId, views);
         }

 

暂时就说到这了,后续有其他地方的修改再进行补充,这方面网上的资料也比较少,本人也走了些弯路,说到底还是比较简单的。

你可能感兴趣的:(Android基本知识)