计算机软件著作权登记-源代码范本.doc

上传人:hw****26 文档编号:4055566 上传时间:2019-09-20 格式:DOC 页数:60 大小:261KB
下载 相关 举报
计算机软件著作权登记-源代码范本.doc_第1页
第1页 / 共60页
计算机软件著作权登记-源代码范本.doc_第2页
第2页 / 共60页
计算机软件著作权登记-源代码范本.doc_第3页
第3页 / 共60页
计算机软件著作权登记-源代码范本.doc_第4页
第4页 / 共60页
计算机软件著作权登记-源代码范本.doc_第5页
第5页 / 共60页
点击查看更多>>
资源描述

1、基于 Android“说呀 ”聊天辅助系统 V1.0 源代码 1package com.example.shuoya;import java.util.Set;import android.content.BroadcastReceiver;import android.content.Context;import android.content.Intent;import android.database.Cursor;import android.database.sqlite.SQLiteDatabase;import android.os.Bundle;import android.t

2、elephony.SmsMessage;import android.util.Log;import android.widget.Toast;public class Breast extends BroadcastReceiver private static final String mACTION = “android.provider.Telephony.SMS_RECEIVED“; Override public void onReceive(Context context, Intent intent) / TODO Auto-generated method stub if (

3、intent.getAction().equals(mACTION) StringBuilder sb = new StringBuilder(); Bundle bundle = intent.getExtras(); if (bundle != null) Set keysSet=bundle.keySet();for(String keyString:keysSet)Log.d(“key“, keyString);Object myOBJpdus = (Object) bundle.get(“pdus“); SmsMessage messages = new SmsMessagemyOB

4、Jpdus.length; for (int i = 0; i coll;private Context ctx;DetailEntity entity;LinearLayout layout;LayoutInflater vi;LinearLayout layout_bj;TextView tvName;TextView tvDate;TextView tvText;public DetailAdapter(Context context, List coll)ctx = context;this.coll = coll;public boolean areAllItemsEnabled()

5、return true;public boolean isEnabled(int arg0)return true;public int getCount()return coll.size();public Object getItem(int position)return coll.get(position);public long getItemId(int position)return position;public int getItemViewType(int position)return position;基于 Android“说呀 ”聊天辅助系统 V1.0 源代码 4pu

6、blic View getView(int position, View convertView, ViewGroup parent)entity = coll.get(position);int itemLayout = entity.getLayoutID();layout = new LinearLayout(ctx);vi = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);vi.inflate(itemLayout, layout, true);layout.setBackgroundCol

7、or(0xffB4B4B4);layout_bj = (LinearLayout) layout.findViewById(R.id.layout_bj);tvName = (TextView) layout.findViewById(R.id.messagedetail_row_name);tvName.setText(entity.getName();tvDate = (TextView) layout.findViewById(R.id.messagedetail_row_date);tvDate.setText(entity.getDate();tvText = (TextView)

8、layout.findViewById(R.id.messagedetail_row_text);tvText.setText(entity.getText();addListener(tvName, tvDate, tvText, layout_bj);return layout;public int getViewTypeCount()return coll.size();public boolean hasStableIds()return true;public boolean isEmpty()return true;Overridepublic void registerDataS

9、etObserver(DataSetObserver observer)/ TODO Auto-generated method stubOverride基于 Android“说呀 ”聊天辅助系统 V1.0 源代码 5public void unregisterDataSetObserver(DataSetObserver observer)/ TODO Auto-generated method stubpublic void addListener(final TextView tvName, final TextView tvDate,final TextView tvText, Lin

10、earLayout layout_bj)layout_bj.setOnClickListener(new OnClickListener()Overridepublic void onClick(View v);/实例并初始化TTS对象 layout_bj.setOnLongClickListener(new OnLongClickListener()Overridepublic boolean onLongClick(final View v)tvName.setTextColor(0xffffffff);tvDate.setTextColor(0xffffffff);tvText.setT

11、extColor(0xffffffff);new AlertDialog.Builder(ctx).setMessage(“说呀聊天辅助系统-应答模式“).setPositiveButton(“确定“,null).show();return true; );/layout_bj.setOnTouchListener(new OnTouchListener()Overridepublic boolean onTouch(View v, MotionEvent event)switch (event.getAction()case MotionEvent.ACTION_DOWN:case Moti

12、onEvent.ACTION_MOVE:tvName.setTextColor(0xffffffff);tvDate.setTextColor(0xffffffff);tvText.setTextColor(0xffffffff);break;default:基于 Android“说呀 ”聊天辅助系统 V1.0 源代码 6tvName.setTextColor(0xff000000);tvDate.setTextColor(0xff000000);tvText.setTextColor(0xff0000ff);break;return false;);package com.example.s

13、huoya;public class DetailEntityprivate String name;private String date;private String text;private int layoutID;public String getName()return name;public void setName(String name)this.name = name;public String getDate()return date;public void setDate(String date)this.date = date;public String getTex

14、t()return text;public void setText(String text)this.text = text;public int getLayoutID()基于 Android“说呀 ”聊天辅助系统 V1.0 源代码 7return layoutID;public void setLayoutID(int layoutID)this.layoutID = layoutID;public DetailEntity()public DetailEntity(String name, String date, String text, int layoutID)super();t

15、his.name = name;this.date = date;this.text = text;this.layoutID = layoutID;package com.example.shuoya;import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;import .URL;import .URLEncoder;public class Fenci /* Called when the activity is first created. */static Str

16、ing u = “http:/ String str;public static String nlp(String func, String input) String str1=“;tryinput = URLEncoder.encode(input, “utf-8“); URL url = new URL( u + func + “/“ + input);StringBuffer sb = new StringBuffer();BufferedReader out = new BufferedReader(new InputStreamReader(url.openStream(), “

17、utf-8“);String line;while (line = out.readLine() != null) sb.append(line);str1=sb.toString();out.close(); catch (IOException e) / TODO Auto-generated catch blocke.printStackTrace();基于 Android“说呀 ”聊天辅助系统 V1.0 源代码 8int i=str1.indexOf(“s“);str1=str1.substring(i+1); return str1; package com.example.shuo

18、ya;import java.io.File;import java.io.FileOutputStream;import java.io.InputStream;import java.io.OutputStream;import java.util.ArrayList;import java.util.List;import com.example.shuoya.R;import android.app.Activity;import android.app.AlertDialog;import android.content.Context;import android.content.

19、DialogInterface;import android.content.Intent;import android.content.pm.PackageManager;import android.content.pm.ResolveInfo;import android.os.Bundle;import android.speech.RecognizerIntent;import android.view.LayoutInflater;import android.view.View;import android.view.Window;import android.view.View

20、.OnClickListener;import android.view.WindowManager;import android.widget.AdapterView;import android.widget.AdapterView.OnItemClickListener;import android.widget.Button;import android.widget.EditText;import android.widget.ListView;import android.widget.PopupWindow;import android.widget.Toast;import a

21、ndroid.database.Cursor;import android.database.sqlite.SQLiteDatabase;import android.graphics.drawable.BitmapDrawable;public class FuzhuActivity extends Activityprivate ListView talkView;private List list = null;/menu菜单模块private PopupWindow popupWindow;private ListView lv_menu;private View view;priva

22、te List Menus;private static final int VOICE_RECOGNITION_REQUEST_CODE = 1234; private EditText mText1;基于 Android“说呀 ”聊天辅助系统 V1.0 源代码 9private Button speakButton;private Button qdButton;private Button chooseButton; long exitTime=-2000;Overridepublic void onCreate(Bundle savedInstanceState)super.onCre

23、ate(savedInstanceState);requestWindowFeature(Window.FEATURE_NO_TITLE);setContentView(R.layout.test);/将数据库放到手机中,测试时注释掉 PackageManager pm = getPackageManager();/管理应用程序包 List activities = pm.queryIntentActivities(new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH), 0); public String getResponce(String

24、 et)String answer=“;String myFenci=Fenci.nlp(“pos“,et);String mySubject,myPredicate,myObject;/定义主谓宾mySubject=GetWord.ReturnSubject(myFenci);myPredicate=GetWord.ReturnPredicate(myFenci);myObject=GetWord.ReturnObject(myFenci);DbAdapter dbHelper = new DbAdapter(FuzhuActivity.this,“test.db“);/只有调用了Datab

25、aseHelper对象的/getReadableDatabase()方法,或者是getWritableDatabase() 方法之后,才会创建,或打开一个数据库SQLiteDatabase db = dbHelper.getReadableDatabase();int id_temp1,id_temp2,id_temp3;String search_id;Cursor cursor1;if(mySubject=null)id_temp1=0;elsecursor1 = db.query(“r_sheet“, new String“id“, “charName=?“, new StringmyS

26、ubject, null, null, null);if(cursor1.moveToNext()/在r表中查询id_temp1=cursor1.getInt(cursor1.getColumnIndex(“id“);elseid_temp1=0;if(myPredicate=null)id_temp2=0;基于 Android“说呀 ”聊天辅助系统 V1.0 源代码 10elsecursor1 = db.query(“verb_sheet“, new String“id“, “verbName=?“, new StringmyPredicate, null, null, null);if(c

27、ursor1.moveToNext()/在v表中查询id_temp2=cursor1.getInt(cursor1.getColumnIndex(“id“);elseid_temp2=0;if(myObject=null)id_temp3=0;elsecursor1 = db.query(“noun_sheet“, new String“id“, “nounName=?“, new StringmyObject, null, null, null);if(cursor1.moveToNext()/在n表中查询id_temp3=cursor1.getInt(cursor1.getColumnIn

28、dex(“id“);elseid_temp3=0;search_id=numberToString(id_temp1)+numberToString(id_temp2)+numberToString(id_temp3);cursor1 = db.query(“answer_sheet“, new String“answer“, “id=?“, new Stringsearch_id, null, null, null);if(cursor1.moveToNext()/在answer 表中查询answer=cursor1.getString(cursor1.getColumnIndex(“ans

29、wer“);elseif(answer!=“)Toast.makeText(getApplicationContext(), answer, Toast.LENGTH_LONG).show(); else if(answer=“) Toast.makeText(getApplicationContext(), “暂无提示 “, Toast.LENGTH_LONG).show(); elseToast.makeText(getApplicationContext(), “暂无提示 “, Toast.LENGTH_LONG).show(); return answer;public String numberToString(int number) String s=“;if (number=0|number10)s=“00“+String.valueOf(number);

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 实用文档资料库 > 策划方案

Copyright © 2018-2021 Wenke99.com All rights reserved

工信部备案号浙ICP备20026746号-2  

公安局备案号:浙公网安备33038302330469号

本站为C2C交文档易平台,即用户上传的文档直接卖给下载用户,本站只是网络服务中间平台,所有原创文档下载所得归上传人所有,若您发现上传作品侵犯了您的权利,请立刻联系网站客服并提供证据,平台将在3个工作日内予以改正。