计算机软件著作权登记-源代码范本.doc_第1页
计算机软件著作权登记-源代码范本.doc_第2页
计算机软件著作权登记-源代码范本.doc_第3页
计算机软件著作权登记-源代码范本.doc_第4页
计算机软件著作权登记-源代码范本.doc_第5页
已阅读5页,还剩55页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

60基于Android“说呀”聊天辅助系统 V1.0 源代码 package 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.telephony.SmsMessage;import android.util.Log;import android.widget.Toast;public class Breast extends BroadcastReceiver private static final String mACTION = vider.Telephony.SMS_RECEIVED; Override public void onReceive(Context context, Intent intent) / TODO Auto-generated method stub if (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 SmsMessagemyOBJpdus.length; for (int i = 0; imyOBJpdus.length; i+) messagesi = SmsMessage.createFromPdu (byte) myOBJpdusi); for (SmsMessage currentMessage : messages) /sb.append(接收到来告:n); /sb.append(currentMessage.getDisplayOriginatingAddress(); /sb.append(n-传来的短信-n); sb.append(currentMessage.getDisplayMessageBody(); Toast.makeText(context, sb, Toast.LENGTH_LONG).show(); Intent i2 = new Intent(context, FuzhuActivity.class); Bundle bundle2=new Bundle(); bundle2.putString(SMS, sb.toString(); i2.putExtra(SMSS, bundle2); i2.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(i2); package com.example.shuoya;import android.content.Context;import android.database.sqlite.SQLiteDatabase;import android.database.sqlite.SQLiteDatabase.CursorFactory;import android.database.sqlite.SQLiteOpenHelper;public class DbAdapter extends SQLiteOpenHelperprivate static final int VERSION = 1;private static final String DBNAME = test.db;public DbAdapter(Context context, String name,CursorFactory factory, int version) super(context, name, factory, version);/ TODO Auto-generated constructor stubpublic DbAdapter(Context context,String name)this(context,name,VERSION);public DbAdapter(Context context)this(context,DBNAME,VERSION);public DbAdapter(Context context,String name,int version)this(context,name,null,VERSION);public void onCreate(SQLiteDatabase db) / TODO Auto-generated method stubpublic void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) / TODO Auto-generated method stubSystem.out.println(update a database);package com.example.shuoya;import java.util.List;import com.example.shuoya.R;import android.app.AlertDialog;import android.content.Context;import android.database.DataSetObserver;import android.view.LayoutInflater;import android.view.MotionEvent;import android.view.View;import android.view.View.OnClickListener;import android.view.View.OnLongClickListener;import android.view.View.OnTouchListener;import android.view.ViewGroup;import android.widget.BaseAdapter;import android.widget.LinearLayout;import android.widget.TextView;/public class DetailAdapter implements ListAdapterpublic class DetailAdapter extends BaseAdapterprivate List 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()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;public 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.setBackgroundColor(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) 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 registerDataSetObserver(DataSetObserver observer)/ TODO Auto-generated method stubOverridepublic void unregisterDataSetObserver(DataSetObserver observer)/ TODO Auto-generated method stubpublic void addListener(final TextView tvName, final TextView tvDate,final TextView tvText, LinearLayout 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.setTextColor(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 MotionEvent.ACTION_MOVE:tvName.setTextColor(0xffffffff);tvDate.setTextColor(0xffffffff);tvText.setTextColor(0xffffffff);break;default:tvName.setTextColor(0xff000000);tvDate.setTextColor(0xff000000);tvText.setTextColor(0xff0000ff);break;return false;);package com.example.shuoya;public class DetailEntityprivate String name;private String date;private String text;private int layoutID;public String getName()return name;public void setName(String name) = name;public String getDate()return date;public void setDate(String date)this.date = date;public String getText()return text;public void setText(String text)this.text = text;public int getLayoutID()return layoutID;public void setLayoutID(int layoutID)this.layoutID = layoutID;public DetailEntity()public DetailEntity(String name, String date, String text, int layoutID)super(); = 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 String u = /fudannlp/; public String str; public static String nlp(String func, String input) String str1=; try input = URLEncoder.encode(input, utf-8); URL url = new URL( u + func + / + input); StringBuffer sb = new StringBuffer(); BufferedReader out = new BufferedReader(new InputStreamReader(url.openStream(), utf-8); String line; while (line = out.readLine() != null) sb.append(line); str1=sb.toString(); out.close(); catch (IOException e) / TODO Auto-generated catch block e.printStackTrace(); int i=str1.indexOf(s); str1=str1.substring(i+1); return str1; package com.example.shuoya;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.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.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 android.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;private List Menus; private static final int VOICE_RECOGNITION_REQUEST_CODE = 1234; private EditText mText1; private Button speakButton; private Button qdButton; private Button chooseButton; long exitTime=-2000; Overridepublic void onCreate(Bundle savedInstanceState)super.onCreate(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 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);/只有调用了DatabaseHelper对象的 /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 Stringid, charName=?, new StringmySubject, null, null, null);if(cursor1.moveToNext()/在r表中查询id_temp1=cursor1.getInt(cursor1.getColumnIndex(id);elseid_temp1=0;if(myPredicate=null)id_temp2=0;elsecursor1 = db.query(verb_sheet, new Stringid, verbName=?, new StringmyPredicate, null, null, null);if(cursor1.moveToNext()/在v表中查询id_temp2=cursor1.getInt(cursor1.getColumnIndex(id);elseid_temp2=0;if(myObject=null)id_temp3=0;elsecursor1 = db.query(noun_sheet, new Stringid, nounName=?, new StringmyObject, null, null, null);if(cursor1.moveToNext()/在n表中查询id_temp3=cursor1.getInt(cursor1.getColumnIndex(id);elseid_temp3=0;search_id=numberToString(id_temp1)+numberToString(id_temp2)+numberToString(id_temp3);cursor1 = db.query(answer_sheet, new Stringanswer, id=?, new Stringsearch_id, null, null, null);if(cursor1.moveToNext()/在answer表中查询answer=cursor1.getString(cursor1.getColumnIndex(answer);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); else if(number100) s=0+String.valueOf(number); else s=String.valueOf(number); return s; package com.example.shuoya;import android.os.AsyncTask; public class GetResTask extends AsyncTaskTestActivity atxs=new TestActivity();Overrideprotected String doInBackground(String. params) / TODO Auto-generated method stubreturn atxs.getResponce(params0); protected Void onPostExcute(String result)return null; package com.example.shuoya;import com.example.shuoya.ManageKeyguard.LaunchOnKeyguardExit;import android.app.Activity;import android.content.Intent;import android.content.SharedPreferences;import android.graphics.Bitmap;import android.os.Bundle;import android.preference.PreferenceManager;import android.view.Display;import android.view.View;import android.view.Window;import android.view.WindowManager;import android.view.View.OnClickListener;import android.widget.Button;import android.widget.ImageView;import android.widget.LinearLayout;import android.widget.ScrollView;import android.widget.TextView;public class SMSPopupActivity extends Activity private SmsMmsMessage message;private boolean exitingKeyguardSecurely = false;private Bundle bundle = null;private SharedPreferences myPrefs;private TextView headerTV; private TextView messageTV;private TextView fromTV;private TextView mmsSubjectTV;private LinearLayout viewButtonLayout;private LinearLayout mmsLinearLayout;private ScrollView messageScrollView;private boolean wasVisible = false;private final double WIDTH = 0.8;Overrideprotected void onCreate(Bundle bundle) super.onCreate(bundle);Log.v(SMSPopupActivity: onCreate();/First things first, acquire wakelock, otherwise the phone may sleepManageWakeLock.acquirePartial(getApplicationContext();requestWindowFeature(Window.FEATURE_NO_TITLE);setContentView(R.layout.popup);/Get shared prefsmyPrefs = PreferenceManager.getDefaultSharedPreferences(this);/Check preferences and then blur out background behind windowif (myPrefs.getBoolean(getString(R.string.pref_blur_key),Boolean.valueOf(getString(R.string.pref_blur_default) getWindow().setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND, WindowManager.LayoutParams.FLAG_BLUR_BEHIND);/This sets the minimum width of the activity to 75% of the screen size/only needed because the theme of this activity is dialog so it looks/like its floating and doesnt seem to fill_parent like a regular activityLinearLayout mainLL = (LinearLayout) findViewById(R.id.MainLinearLayout);Display d = getWindowManager().getDefaultDisplay();int width = (int)(d.getWidth() * WIDTH);Log.v(setting width to: + width);mainLL.setMinimumWidth(width);/Find the main textviewsfromTV = (TextView) findViewById(R.id.FromTextView);messageTV = (TextView) findViewById(R.id.MessageTextView);headerTV = (TextView) findViewById(R.id.HeaderTextView);mmsSubjectTV = (TextView) findViewById(R.id.MmsSubjectTextView);viewButtonLayout = (LinearLayout) findViewById(R.id.ViewButtonLinearLayout);messageScrollView = (ScrollView) findViewById(R.id.MessageScrollView);mmsLinearLayout = (LinearLayout) findViewById(R.id.MmsLinearLayout);/The close buttonButton closeButton = (Button) findViewById(R.id.closeButton);closeButton.setOnClickListener(new OnClickListener() public void onClick(View v) Intent i = new Intent(SMSPopupActivity.this.getApplicationContext(), SMSPopupUtilsService.class);/ i.putExtra(SMSPopupUtilsService.EXTRAS_THREAD_ID,/ message.getThreadId();i.setAction(SMSPopupUtilsService.ACTION_MARK_THREAD_READ);i.putExtras(message.toBundle();SMSPopupUtilsService.beginStartingService(SMSPopupActivity.this.getApplicationContext(), i);/ Finish up this activitymyFinish(););/The inbox buttonButton inboxButton = (Button) findViewById(R.id.InboxButton);inboxButton.setOnClickListener(new OnClickListener() public void onClick(View v) exitingKeyguardSecurely = true;ManageKeyguard.exitKeyguardSecurely(new LaunchOnKeyguardExit() public void LaunchOnKeyguardExitSuccess() Intent i = SMSPopupUtils.getSmsIntent();SMSPopupActivity.this.getApplicationContext().startActivity(i); );myFinish(

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论