有网友提出了几种方法,经测试后有问题,不知何故? 
1.  调用switchInputMethod()方法
    例如设置成日文输入法,先获取日文输入法ID。
    Lis<InputMethodInfo> InputMethods = ((InputMethodManager)MyActivity.this.getSystemService( Context.INPUT_METHOD_SERVICE) ).getEnabledInputMethodList();//系统中有三个输入法: 拼音、日文、西文
    String IMEId= InputMethods.get( 1 ).getId();//获取日文输入法ID
    有网友提出该方法( 没有具体的源码 ),但不知如何获取InputMethoService,调用其方法InputMethoService.switchInputMethod( IMEId );2.  通过Setting.Secure.putString()方法
    String IMEName = InputMethods.get( 1 ).getServiceName();//获取日文输入法Name
    Setting.Secure.putString( MyActivity.this.getContentResolver(), Setting.Secure.DEFAULT_INPUT_METHOD, IMEName );    同时要在AndroidManifest.xml添加权限申请:
    <use-permission android:name="android.permission.WRITE_SETTING"/>
    <use-permission android:name="android.permission.WRITE_SECURE_SETTING"/>    测试后总是抛出异常:Permission Denial: writing com,android.providers.settings.SettingsProvider ...3. 通过(InputMethodManager)getSystemService( Context.INPUT_METHOD_SERVICE) ).setInputMethodList( null, IMEId );
    同样会抛出异常:Permission Denial: writing com,android.providers.settings.SettingsProvider ...    有哪位大侠帮帮忙吧!! 回复有积分喔。

解决方案 »

  1.   

    可以看下源码LatinIME中有关输入法选择设置的源码。
      

  2.   

    参考下Android 3.0 r1中文API文档(103) —— InputMethodManager [输入法]:http://www.cnblogs.com/over140/archive/2011/03/04/1970517.html
      

  3.   

    同样会抛出异常:Permission Denial
    这不是permission问题吗? 是不是你的用应加了权限就可以了? 路过
      

  4.   

     <uses-permission> tag needs to be a direct child of the <manifest> tag, not the <application> tag.
      

  5.   

    呵呵,最近我也再做这个,首先
    1.witchInputMethod() 这个方法来自InputMethoService  这个系统的Service你是获取不到的。
    2.setting 这个不光要把权限加上去,还必须你的程序在system/app下,也就是系统程序
    3.应该和2是同理。
    我更悲催,因为我不是要在自己的程序里切换输入法,而是做一个应用来控制别的程序的输入法。。android的输入法安全机制很好,要操作输入法就要获取token,一般来说除自己程序本身来说其他程序是获取不到你的程序的token的,所以我只能在framework层改,特别的麻烦,因为他涉及到焦点一些问题,所以如果想切换的话
    1.程序是系统程序
    2.改framework
      

  6.   

    有网友说使用Android系统对应版本的platform密钥签名,但无法得到Android2.1源码或仅仅Android2.1或1.5的密钥和签名工具,暂时无法测试。
    有那位高手能分享一下?