Android日语输入法Simeji使用示例

简介: MainActivity如下: package cn.testsimeji;import android.os.Bundle;import android.

MainActivity如下:

package cn.testsimeji;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.app.Activity;
import android.content.Intent;
/**
 * Demo描述:
 * simeji使用示例
 * 
 * 注意事项:
 * 1 在配置文件中添加
 *   <action android:name="com.adamrocker.android.simeji.ACTION_INTERCEPT" />
 *   <category android:name="com.adamrocker.android.simeji.REPLACE" />
 *   <category android:name="android.intent.category.DEFAULT" />
 * 2 此处的REPLACE_KEY的设值.不可随意更改.
 * 
 * 官方文档:
 * http://simeji.me/blog/make_mushroom
 */
public class MainActivity extends Activity {
	private static final String ACTION_INTERCEPT = "com.adamrocker.android.simeji.ACTION_INTERCEPT";
	private static final String REPLACE_KEY = "replace_key";
	private Button mButton;
	private String rawContent;
	private String newContent;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		init();
		
	}

	private void init() {
		mButton = (Button) findViewById(R.id.button);
		mButton.setOnClickListener(new OnClickListenerImpl());

		Intent intent = this.getIntent();
		String action = intent.getAction();
		if (action != null && ACTION_INTERCEPT.equals(action)) {
             System.out.println("开始调用文字替换");
             rawContent=intent.getStringExtra(REPLACE_KEY);
             System.out.println("rawContent="+rawContent);
		} else {
			 System.out.println("没有调用到文字替换");
		}

	}

	private class OnClickListenerImpl implements OnClickListener {
		@Override
		public void onClick(View v) {
			Intent data = new Intent();
			newContent="hello everybody";
			data.putExtra(REPLACE_KEY, newContent);
			setResult(RESULT_OK, data);
			finish();
		}

	}

}


 

main.xml如下:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
   >

    <Button
        android:id="@+id/button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="replace text" 
        android:layout_centerInParent="true"
        />

</RelativeLayout>


AndroidManifest.xml如下:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="cn.testsimeji"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="8" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="cn.testsimeji.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
                
                <action android:name="com.adamrocker.android.simeji.ACTION_INTERCEPT" />
				<category android:name="com.adamrocker.android.simeji.REPLACE" />
				<category android:name="android.intent.category.DEFAULT" />
				
            </intent-filter>
        </activity>
        
        
      
        
    </application>

</manifest>


 

相关文章
|
4月前
|
存储 算法 开发工具
OpenCV 安卓编程示例:1~6 全
OpenCV 安卓编程示例:1~6 全
61 0
|
8月前
|
编解码 监控 API
Android平台GB28181设备接入侧音频采集推送示例
GB/T28181是广泛应用于视频监控行业的标准协议规范,可以在不同设备之间实现互联互通。今天我们主要探讨Android平台的Audio采集部分。
|
3天前
|
Android开发
Android 高通平台集成无源码apk示例
Android 高通平台集成无源码apk示例
12 0
|
18天前
|
存储 安全 文件存储
Android OTA升级后输入法异常和应用丢失的分析
Android OTA升级后输入法异常和应用丢失的分析
20 1
|
11月前
|
XML Android开发 数据格式
Android输入法挤乱布局问题
Android输入法挤乱布局问题
|
网络协议 Linux API
Android C++ 系列:Linux Socket 编程(三)CS 模型示例
服务器调用socket()、bind()、listen()完成初始化后,调用accept()阻塞等待,处于 监听端口的状态,客户端调用socket()初始化后,调用connect()发出SYN段并阻塞等待服 务器应答,服务器应答一个SYN-ACK段,客户端收到后从connect()返回,同时应答一个ACK 段,服务器收到后从accept()返回。
127 0
|
编解码 Android开发
android 输入法不全屏
android 输入法不全屏
155 0
|
Android开发
android 检测外接键盘并设置输入法布局
android 检测外接键盘并设置输入法布局
340 0
|
Android开发
android 修改输入法中拼写检测默认值
android 修改输入法中拼写检测默认值
57 0
|
Android开发
Android点击空白区域,隐藏输入法软键盘
Android点击空白区域,隐藏输入法软键盘
598 0