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

下载本文档

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

文档简介

..packagecom.example.shuoya;importjava.util.Set;importandroid.content.BroadcastReceiver;importandroid.content.Context;importandroid.content.Intent;importandroid.database.Cursor;importandroid.database.sqlite.SQLiteDatabase;le;importandroid.telephony.SmsMessage;importandroid.util.Log;importandroid.widget.Toast;publicclassBreastextendsBroadcastReceiver{privatestaticfinalStringmACTION="vider.Telephony.SMS_RECEIVED";OverridepublicvoidonReceive<Contextcontext,Intentintent>{//TODOAuto-generatedmethodstubif<intent.getAction<>.equals<mACTION>>{StringBuildersb=newStringBuilder<>;Bundlebundle=intent.getExtras<>;if<bundle!=null>{Set<String>keysSet=bundle.keySet<>;for<StringkeyString:keysSet>{Log.d<"key",keyString>;}Object[]myOBJpdus=<Object[]>bundle.get<"pdus">;SmsMessage[]messages=newSmsMessage[myOBJpdus.length];for<inti=0;i<myOBJpdus.length;i++>{messages[i]=SmsMessage.createFromPdu<<byte[]>myOBJpdus[i]>;}for<SmsMessagecurrentMessage:messages>{//sb.append<"接收到来告:\n">;//sb.append<currentMessage.getDisplayOriginatingAddress<>>;//sb.append<"\n------传来的短信------\n">;sb.append<currentMessage.getDisplayMessageBody<>>;}}Toast.makeText<context,sb,Toast.LENGTH_LONG>.show<>;Intenti2=newIntent<context,FuzhuActivity.class>;Bundlebundle2=newBundle<>;bundle2.putString<"SMS",sb.toString<>>;i2.putExtra<"SMSS",bundle2>;i2.addFlags<Intent.FLAG_ACTIVITY_NEW_TASK>;context.startActivity<i2>;}}}packagecom.example.shuoya;importandroid.content.Context;importandroid.database.sqlite.SQLiteDatabase;importandroid.database.sqlite.SQLiteDatabase.CursorFactory;qlite.SQLiteOpenHelper;publicclassDbAdapterextendsSQLiteOpenHelper{ privatestaticfinalintVERSION=1; privatestaticfinalStringDBNAME="test.db"; publicDbAdapter<Contextcontext,Stringname, CursorFactoryfactory,intversion>{ super<context,name,factory,version>; //TODOAuto-generatedconstructorstub } publicDbAdapter<Contextcontext,Stringname>{ this<context,name,VERSION>; } publicDbAdapter<Contextcontext>{ this<context,DBNAME,VERSION>; } publicDbAdapter<Contextcontext,Stringname,intversion>{ this<context,name,null,VERSION>; } publicvoidonCreate<SQLiteDatabasedb>{ //TODOAuto-generatedmethodstub } publicvoidonUpgrade<SQLiteDatabasedb,intoldVersion,intnewVersion>{ //TODOAuto-generatedmethodstub System.out.println<"updateadatabase">; }}packagecom.example.shuoya;importjava.util.List;importcom.example.shuoya.R;importandroid.app.AlertDialog;importandroid.content.Context;importandroid.database.DataSetObserver;importandroid.view.LayoutInflater;importandroid.view.MotionEvent;importandroid.view.View;importandroid.view.View.OnClickListener;importandroid.view.View.OnLongClickListener;importandroid.view.View.OnTouchListener;importandroid.view.ViewGroup;importandroid.widget.BaseAdapter;importandroid.widget.LinearLayout;importandroid.widget.TextView;//publicclassDetailAdapterimplementsListAdapterpublicclassDetailAdapterextendsBaseAdapter{ privateList<DetailEntity>coll; privateContextctx; DetailEntityentity; LinearLayoutlayout; LayoutInflatervi; LinearLayoutlayout_bj; TextViewtvName; TextViewtvDate; TextViewtvText; publicDetailAdapter<Contextcontext,List<DetailEntity>coll> { ctx=context; this.coll=coll; } publicbooleanareAllItemsEnabled<> { returntrue; } publicbooleanisEnabled<intarg0> { returntrue; } publicintgetCount<> { returncoll.size<>; } publicObjectgetItem<intposition> { returncoll.get<position>; } publiclonggetItemId<intposition> { returnposition; } publicintgetItemViewType<intposition> { returnposition; } publicViewgetView<intposition,ViewconvertView,ViewGroupparent> { entity=coll.get<position>; intitemLayout=entity.getLayoutID<>; layout=newLinearLayout<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>; returnlayout; } publicintgetViewTypeCount<> { returncoll.size<>; } publicbooleanhasStableIds<> { returntrue; } publicbooleanisEmpty<> { returntrue; } Override publicvoidregisterDataSetObserver<DataSetObserverobserver> { //TODOAuto-generatedmethodstub } Override publicvoidunregisterDataSetObserver<DataSetObserverobserver> { //TODOAuto-generatedmethodstub } publicvoidaddListener<finalTextViewtvName,finalTextViewtvDate, finalTextViewtvText,LinearLayoutlayout_bj> { layout_bj.setOnClickListener<newOnClickListener<> { Override publicvoidonClick<Viewv> { } }>; //实例并初始化TTS对象 layout_bj.setOnLongClickListener<newOnLongClickListener<> { Override publicbooleanonLongClick<finalViewv> { tvName.setTextColor<0xffffffff>; tvDate.setTextColor<0xffffffff>; tvText.setTextColor<0xffffffff>; newAlertDialog.Builder<ctx>.setMessage<"说呀聊天辅助系统-应答模式">.setPositiveButton<"确定",null> .show<>; returntrue; } }>;//// layout_bj.setOnTouchListener<newOnTouchListener<> { Override publicbooleanonTouch<Viewv,MotionEventevent> { switch<event.getAction<>> { caseMotionEvent.ACTION_DOWN: caseMotionEvent.ACTION_MOVE: tvName.setTextColor<0xffffffff>; tvDate.setTextColor<0xffffffff>; tvText.setTextColor<0xffffffff>; break; default: tvName.setTextColor<0xff000000>; tvDate.setTextColor<0xff000000>; tvText.setTextColor<0xff0000ff>; break; } returnfalse; } }>; }}packagecom.example.shuoya;publicclassDetailEntity{ privateStringname; privateStringdate; privateStringtext; privateintlayoutID; publicStringgetName<> { returnname; } publicvoidsetName<Stringname> { =name; } publicStringgetDate<> { returndate; } publicvoidsetDate<Stringdate> { this.date=date; } publicStringgetText<> { returntext; } publicvoidsetText<Stringtext> { this.text=text; } publicintgetLayoutID<> { returnlayoutID; } publicvoidsetLayoutID<intlayoutID> { this.layoutID=layoutID; } publicDetailEntity<> { } publicDetailEntity<Stringname,Stringdate,Stringtext,intlayoutID> { super<>; =name; this.date=date; this.text=text; this.layoutID=layoutID; }}packagecom.example.shuoya;importjava.io.BufferedReader;importjava.io.IOException;importjava.io.InputStreamReader;.URL;.URLEncoder;publicclassFenci{/*Calledwhentheactivityisfirstcreated.*/ staticStringu=":///fudannlp/";publicStringstr;publicstaticStringnlp<Stringfunc,Stringinput>{ Stringstr1="";try{ input=URLEncoder.encode<input,"utf-8">;URLurl=newURL<u+func+"/"+input>;StringBuffersb=newStringBuffer<>;BufferedReaderout=newBufferedReader<newInputStreamReader<url.openStream<>,"utf-8">>;Stringline;while<<line=out.readLine<>>!=null>sb.append<line>; str1=sb.toString<>; out.close<>;}catch<IOExceptione>{ //TODOAuto-generatedcatchblock e.printStackTrace<>; }inti=str1.indexOf<"s">;str1=str1.substring<i+1>;returnstr1;}}packagecom.example.shuoya;importjava.io.File;importjava.io.FileOutputStream;importjava.io.InputStream;importjava.io.OutputStream;importjava.util.ArrayList;importjava.util.List;importcom.example.shuoya.R;importandroid.app.Activity;importandroid.app.AlertDialog;importandroid.content.Context;importandroid.content.DialogInterface;importandroid.content.Intent;importandroid.content.pm.PackageManager;importandroid.content.pm.ResolveInfo;importandroid.os.Bundle;importandroid.speech.RecognizerIntent;importandroid.view.LayoutInflater;importandroid.view.View;importandroid.view.Window;importandroid.view.View.OnClickListener;dowManager;importandroid.widget.AdapterView;importandroid.widget.AdapterView.OnItemClickListener;importandroid.widget.Button;importandroid.widget.EditText;importandroid.widget.ListView;importandroid.widget.PopupWindow;st;importandroid.database.Cursor;importandroid.database.sqlite.SQLiteDatabase;importandroid.graphics.drawable.BitmapDrawable;publicclassFuzhuActivityextendsActivity{ privateListViewtalkView; privateList<DetailEntity>list=null; //menu菜单模块 privatePopupWindowpopupWindow; privateListViewlv_menu; privateViewview; privateList<String>Menus;privatestaticfinalintVOICE_RECOGNITION_REQUEST_CODE=1234;privateEditTextmText1;privateButtonspeakButton;privateButtonqdButton;privateButtonchooseButton; longexitTime=-2000; Override publicvoidonCreate<BundlesavedInstanceState> { super.onCreate<savedInstanceState>; requestWindowFeature<Window.FEATURE_NO_TITLE>; setContentView<R.layout.test>;//将数据库放到手机中,测试时注释掉 PackageManagerpm=getPackageManager<>;//管理应用程序包List<ResolveInfo>activities=pm.queryIntentActivities<newIntent<RecognizerIntent.ACTION_RECOGNIZE_SPEECH>,0>;}publicStringgetResponce<Stringet>{ Stringanswer=""; StringmyFenci=Fenci.nlp<"pos",et>; StringmySubject,myPredicate,myObject;//定义主谓宾 mySubject=GetWord.ReturnSubject<myFenci>; myPredicate=GetWord.ReturnPredicate<myFenci>; myObject=GetWord.ReturnObject<myFenci>; DbAdapterdbHelper=newDbAdapter<FuzhuActivity.this,"test.db">; //只有调用了DatabaseHelper对象的//getReadableDatabase<>方法,或者是getWritableDatabase<>方法之后,才会创建,或打开一个数据库 SQLiteDatabasedb=dbHelper.getReadableDatabase<>; intid_temp1,id_temp2,id_temp3; Stringsearch_id; Cursorcursor1; if<mySubject==null> { id_temp1=0; } else { cursor1=db.query<"r_sheet",newString[]{"id"},"charName=?",newString[]{mySubject},null,null,null>; if<cursor1.moveToNext<>>{//在r表中查询 id_temp1=cursor1.getInt<cursor1.getColumnIndex<"id">>; } else{ id_temp1=0; } } if<myPredicate==null> { id_temp2=0; } else { cursor1=db.query<"verb_sheet",newString[]{"id"},"verbName=?",newString[]{myPredicate},null,null,null>; if<cursor1.moveToNext<>>{//在v表中查询 id_temp2=cursor1.getInt<cursor1.getColumnIndex<"id">>; } else{ id_temp2=0; } } if<myObject==null> { id_temp3=0; } else { cursor1=db.query<"noun_sheet",newString[]{"id"},"nounName=?",newString[]{myObject},null,null,null>; if<cursor1.moveToNext<>>{//在n表中查询 id_temp3=cursor1.getInt<cursor1.getColumnIndex<"id">>; } else{ id_temp3=0; } } search_id=numberToString<id_temp1>+numberToString<id_temp2>+numberToString<id_temp3>; cursor1=db.query<"answer_sheet",newString[]{"answer"},"id=?",newString[]{search_id},null,null,null>; if<cursor1.moveToNext<>>{//在answer表中查询 answer=cursor1.getString<cursor1.getColumnIndex<"answer">>; } else{ } if<answer!="">{ Toast.makeText<getApplicationContext<>,answer,Toast.LENGTH_LONG>.show<>; } elseif<answer=="">{ Toast.makeText<getApplicationContext<>,"暂无提示",Toast.LENGTH_LONG>.show<>; } else{ Toast.makeText<getApplicationContext<>,"暂无提示",Toast.LENGTH_LONG>.show<>; } returnanswer; } publicStringnumberToString<intnumber>{ Strings=""; if<number==0||number<10> s="00"+String.valueOf<number>;elseif<number<100> s="0"+String.valueOf<number>; else s=String.valueOf<number>;returns; }}packagecom.example.shuoya;importandroid.os.AsyncTask;publicclassGetResTaskextendsAsyncTask<String,Void,String>{ TestActivityatxs=newTestActivity<>; Override protectedStringdoInBackground<String...params>{ //TODOAuto-generatedmethodstub returnatxs.getResponce<params[0]>; } protectedVoidonPostExcute<Stringresult>{ returnnull; }}packagecom.example.shuoya;importcom.example.shuoya.ManageKeyguard.LaunchOnKeyguardExit;importandroid.app.Activity;importandroid.content.Intent;importandroid.content.SharedPreferences;importandroid.graphics.Bitmap;importandroid.os.Bundle;enceManager;importandroid.view.Display;importandroid.view.View;importandroid.view.Window;importandroid.view.WindowManager;importandroid.view.View.OnClickListener;importandroid.widget.Button;importandroid.widget.ImageView;importandroid.widget.LinearLayout;importandroid.widget.ScrollView;importandroid.widget.TextView;publicclassSMSPopupActivityextendsActivity{ privateSmsMmsMessagemessage; privatebooleanexitingKeyguardSecurely=false; privateBundlebundle=null; privateSharedPreferencesmyPrefs; privateTextViewheaderTV; privateTextViewmessageTV; privateTextViewfromTV; privateTextViewmmsSubjectTV; privateLinearLayoutviewButtonLayout; privateLinearLayoutmmsLinearLayout; privateScrollViewmessageScrollView; privatebooleanwasVisible=false; privatefinaldoubleWIDTH=0.8; Override protectedvoidonCreate<Bundlebundle>{ super.onCreate<bundle>; Log.v<"SMSPopupActivity:onCreate<>">; //Firstthingsfirst,acquirewakelock,otherwisethephonemaysleep ManageWakeLock.acquirePartial<getApplicationContext<>>; requestWindowFeature<Window.FEATURE_NO_TITLE>; setContentView<R.layout.popup>; //Getsharedprefs myPrefs=PreferenceManager.getDefaultSharedPreferences<this>; //Checkpreferencesandthenbluroutbackgroundbehindwindow if<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>; } //Thissetstheminimumwidthoftheactivityto75%ofthescreensize //onlyneededbecausethethemeofthisactivityis"dialog"soitlooks //likeit'sfloatinganddoesn'tseemtofill_parentlikearegularactivity LinearLayoutmainLL=<LinearLayout>findViewById<R.id.MainLinearLayout>; Displayd=getWindowManager<>.getDefaultDisplay<>; intwidth=<int><d.getWidth<>*WIDTH>; Log.v<"settingwidthto:"+width>; mainLL.setMinimumWidth<width>; //Findthemaintextviews fromTV=<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>;sLinearLayout>; //Theclosebutton ButtoncloseButton=<Button>findViewById<R.id.closeButton>; closeButton.setOnClickListener<newOnClickListener<>{ publicvoidonClick<Viewv>{icationContext<>, 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>; //Finishupthisactivity myFinish<>; } }>; //Theinboxbutton ButtoninboxButton=<Button>findViewById<R.id.InboxButton>; inboxButton.setOnClickListener<newOnClickListener<>{ publicvoidonClick<Viewv>{ exitingKeyguardSecurely=true; ManageKeyguard.exitKeyguardSecurely<newLaunchOnKeyguardExit<>{ publicvoidLaunchOnKeyguardExitSuccess<>{ Intenti=SMSPopupUtils.getSmsIntent<>; SMSPopupActivity.this.getApplicationContext<>.startActivity<i>;} }>; myFinish<>; } }>; //Theviewbutton<ifinprivacymode> ButtonviewButton=<Button>findViewById<R.id.ViewButton>; viewButton.setOnClickListener<newOnClickListener<>{ publicvoidonClick<Viewv>{ exitingKeyguardSecurely=true; ManageKeyguard.exitKeyguardSecurely<newLaunchOnKeyguardExit<>{ publicvoidLaunchOnKeyguardExitSuccess<>{ Intenti=getIntent<>; i.putExtra<SmsMmsMessage.EXTRAS_NOTIFY,false>; startActivity<i>; //finish<>;} }>; } }>; //Thereplybutton ButtonreplyButton=<Button>findViewById<R.id.replyButton>; replyButton.setOnClickListener<newOnClickListener<>{ publicvoidonClick<Viewv>{ exitingKeyguardSecurely=true; ManageKeyguard.exitKeyguardSecurely<newLaunchOnKeyguardExit<>{ publicvoidLaunchOnKeyguardExitSuccess<>{ Intentreply=message.getReplyIntent<>; SMSPopupActivity.this.getApplicationContext<>.startActivity<reply>;} }>; ManageNotification.clearAll<SMSPopupActivity.this.getApplicationContext<>,true>; myFinish<>; } }>; //TheViewMMSbutton ButtonviewMmsButton=<Button>findViewById<R.id.ViewMmsButton>; viewMmsButton.setOnClickListener<newOnClickListener<>{ publicvoidonClick<Viewv>{ exitingKeyguardSecurely=true; ManageKeyguard.exitKeyguardSecurely<newLaunchOnKeyguardExit<>{ publicvoidLaunchOnKeyguardExitSuccess<>{ Intentreply=message.getReplyIntent<>; SMSPopupActivity.this.getApplicationContext<>.startActivity<reply>; } }>;ionContext<>,true>; myFinish<>; } }>; if<bundle==null>{ populateViews<getIntent<>.getExtras<>>; }else{ populateViews<bundle>; } wakeApp<>; } Override protectedvoidonNewIntent<Intentintent>{ super.onNewIntent<intent>; Log.v<"SMSPopupActivity:onNewIntent<>">; //Firstthingsfirst,acquirewakelock,otherwisethephonemaysleep ManageWakeLock.acquirePartial<getApplicationContext<>>; setIntent<intent>; //Re-populateviewswithnewintentdata<ie.newsmsdata> populateViews<intent.getExtras<>>; wakeApp<>; } Override protectedvoidonStart<>{ super.onStart<>; Log.v<"SMSPopupActivity:onStart<>">; ManageWakeLock.acquirePartial<getApplicationContext<>>; } Override protectedvoidonResume<>{ super.onResume<>; Log.v<"SMSPopupActivity:onResume<>">; wasVisible=false; //ResetexitingKeyguardSecurelybooltofalse exitingKeyguardSecurely=false; } Override protectedvoidonPause<>{ super.onPause<>; Log.v<"SMSPopupActivity:onPause<>">; if<wasVisible>{ //Cancelthereceiverthatwillclearourlocks ClearAllReceiver.removeCancel<getApplicationContext<>>; ClearAllReceiver.clearAll<!exitingKeyguardSecurely>; } } Override protectedvoidonStop<>{ super.onStop<>; Log.v<"SMSPopupActivity:onStop<>">; //Cancelthereceiverthatwillclearourlocks ClearAllReceiver.removeCancel<getApplicationContext<>>; ClearAllReceiver.clearAll<!exitingKeyguardSecurely>; } Override publicvoidonWindowFocusChanged<booleanhasFocus>{ super.onWindowFocusChanged<hasFocus>; Log.v<"SMSPopupActivity:onWindowFocusChanged<"+hasFocus+">">; if<hasFocus>{ wasVisible=true; } } Override publicvoidonSaveInstanceState<BundleoutState>{ super.onSaveInstanceState<outState>; Log.v<"SMSPopupActivity:onSaveInstanceState<>">; outState.putAll<bundle>; } privatevoidmyFinish<>{ ManageNotification.clearAll<getApplicationContext<>>; ReminderReceiver.cancelReminder<getApplicationContext<>>; finish<>; } privatevoidpopulateViews<Bundleb>{ bundle=b; message=newSmsMmsMessage<getApplicationContext<>,bundle>; refreshPrivacy<>; ImageViewiv=<ImageView>findViewById<R.id.FromImageView>; BitmapcontactPhoto=message.getContactPhoto<>; if<contactPhoto!=null>{ iv.setImageBitmap<contactPhoto>; }else{ iv.setImageDrawable< getResources<>.getDrawable<android.R.drawable.ic_dialog_info>>; } LinearLayoutmLL=<LinearLayout>findViewById<R.id.UnreadCountLinearLayout>; TextViewtv=<TextView>findViewById<R.id.UnreadCountTextView>; if<message.getUnreadCount<><=1>{ mLL.setVisibility<View.GONE>; tv.setText<"">; }else{ StringtextWaiting=String.format< getString<R.string.unread_text_waiting>,message .getUnreadCount<>-1>; tv.setText<textWaiting>; mLL.setVisibility<View.VISIBLE>; } StringheaderText=getString<R.string.new_text_at>; headerText=headerText.replaceAll<"%s",message.getFormattedTimestamp<>>; fromTV.setText<message.getContactName<>>; if<message.getMessageType<>==SmsMmsMessage.MESSAGE_TYPE_SMS>{ messageTV.setText<message.getMessageBody<>>; }else{ mmsSubjectTV.setText<getString<R.string.mms_subject>+""+message.getMessageBody<>>; } headerTV.setText<headerText>; } privatevoidrefreshPrivacy<>{ ManageKeyguard.initialize<getApplicationContext<>>; booleanprivacyMode=myPrefs.getBoolean< getString<R.string.pref_privacy_key>, Boolean.valueOf<getString<R.string.pref_privacy_default>>>; if<message.getMessageType<>==SmsMmsMessage.MESSAGE_TYPE_MMS>{ viewButtonLayout.setVisibility<View.GONE>; messageScrollView.setVisibility<View.GONE>; mmsLinearLayout.setVisibility<View.VISIBLE>; booleansubjectAvailable=true; if<message.getMessageBody<>==null>{ subjectAvailable=false; }else{ if<message.getMessageBody<>.length<>==0>{ subjectAvailable=false; } } if<!subjectAvailable>{ mmsSubjectTV.setVisibility<View.GONE>; }else{ mmsSubjectTV.setVisibility<View.VISIBLE>; } }else{ mmsLinearLayout.setVisibility<View.GONE>; if<privacyMode&&ManageKeyguard.inKeyguardRestrictedInputMode<>>{ viewButtonLayout.setVisibility<View.VISIBLE>; messageScrollView.setVisibility<View.GONE>; }else{ viewButtonLayout.setVisibility<View.GONE>; messageScrollView.setVisibility<View.VISIBLE>; } } } privatevoidwakeApp<>{ ManageWakeLock.acquireFull<getApplicationContext<>>; if<message.getNotify<>>{ bundle.putBoolean<SmsMmsMessage.EXTRAS_NOTIFY,false>; message.updateReminderCount<0>; ReminderReceiver.scheduleReminder<getApplicationContext<>,message>; ManageNotification.show<getApplicationContext<>,message>; } } Override protectedvoidonDestroy<>{ Log.v<"onDestroy<>">; super.onDestroy<>; }}packagecom.example.shuoya;importandroid.content.BroadcastReceiver;importandroid.content.Context;;publicclassSMSReceiverextendsBroadcastReceiver{ Override publicvoidonReceive<Contextcontext,Intentintent>{ Log.v<"SMSReceiver:onReceive<>">; intent.setClass<context,SMSReceiverService.class>; intent.putExtra<"result",getResultCode<>>; SMSReceiverService.beginStartingService<context,intent>; }}packagecom.example.shuoya;importandroid.app.AlarmManager;importandroid.app.PendingIntent;importandroid.content.BroadcastReceiver;importandroid.content.Context;importandroid.content.Intent;importandroid.content.SharedPreferences;importandroid.preference.PreferenceManager;publicclassReminderReceiverextendsBroadcastReceiver{ privatestaticPendingIntentreminderPendingIntent=null; Override publicvoidonReceive<Contextcontext,Intentintent>{ intent.setClass<context,ReminderReceiverService.class>; ReminderReceiverService.beginStartingService<context,intent>; } publicstaticvoidscheduleReminder<Contextcontext,SmsMmsMessagemessage>{ SharedPreferencesmyPrefs=PreferenceManager.getDefaultSharedPreferences<context>; booleanreminder_notifications=myPrefs.getBoolean<context .getString<R.string.pref_notif_repeat_key>,Boolean.valueOf<contextefault>>>; if<reminder_notifications>{ intreminder_interval=Integer.parseInt<myPrefs.getString<context .getString<R.string.pref_notif_repeat_interval_key>,context .getString<R.string.pref_notif_repeat_interval_default>>>; reminder_interval*=60; AlarmManagermyAM=<AlarmManager>context.getSystemService<Context.ALARM_SERVICE>; IntentreminderIntent=newIntent<context,ReminderReceiver.class>; reminderIntent.setAction<ReminderReceiverService.ACTION_REMIND>; message.incrementReminderCount<>; reminderIntent.putExtras<message.toBundle<>>; reminderPendingIntent=PendingIntent.getBroadcast<context,0,reminderIntent, PendingIntent.FLAG_CANCEL_CURRENT>; longtriggerTime=System.currentTimeMillis<>+<reminder_interval*1000>; Log.v<"ReminderReceiver:scheduledremindernotificationin"+reminder_interval +"seconds,countis"+message.getReminderCount<>>; myAM.set<AlarmManager.RTC_WAKEUP,triggerTime,reminderPendingIntent>; } } publicstaticvoidcancelReminder<Contextcontext>{ if<reminderPendingIntent!=null>{ AlarmManagermyAM=<AlarmManager>context.getSystemService<Context.ALARM_SERVICE>; myAM.cancel<reminderPendingIntent>; reminderPendingIntent.cancel<>; reminderPendingIntent=null; Log.v<"ReminderReceiver:cancelReminder<>">; } }}packagecom.example.shuoya;importandroid.app.Activity;importandroid.app.Service;importandroid.content.Context;importandroid.content.Intent;importandroid.content.SharedPreferences;importandroid.os.Bundle;importandroid.os.Handler;importandroid.os.HandlerThread;importandroid.os.IBinder;importandroid.os.Looper;importandroid.os.Message;importandroid.os.PowerManager;;importandroid.preference.PreferenceManager;importandroid.telephony.gsm.SmsManager;importandroid.telephony.gsm.SmsMessage;publicclassSMSReceiverServiceextendsService{ny.SMS_RECEIVED"; privatestaticfinalStringACTION_MMS_RECEIVED="vider.Telephony.WAP_PUSH_RECEIVED"; privatestaticfinalStringMMS_DATA_TYPE="application/vnd.wap.mms-message";privatestaticfinalStringACTION_MESSAGE_SENT="com.android.mms.transaction.MESSAGE_SENT"; privateContextcontext;privateServiceHandlermServiceHandler; privateLoopermServiceLooper; privateintmResultCode; staticfinalObjectmStartingServiceSync=newObject<>; staticPowerManager.WakeLockmStartingService; Override publicvoidonCreate<>{ Log.v<"SMSReceiverService:onCreate<>">; HandlerThreadthread=newHandlerThread<Log.LOGTAG,Process.THREAD_PRIORITY_BACKGROUND>; thread.start<>; context=getApplicationContext<>; mServiceLooper=thread.getLooper<>; mServiceHandler=newServiceHandler<mServiceLooper>; }Override publicvoidonStart<Intentintent,intstartId>{ Log.v<"SMSReceiverService:onStart<>">; mResultCode=intent.getIntExtra<"result",0>; Messagemsg=mServiceHandler.obtainMessage<>; msg.arg1=startId; msg.obj=intent; mServiceHandler.sendMessage<msg>; } Override publicvoidonDestroy<>{ Log.v<"SMSReceiverService:onDestroy<>">; mServiceLooper.quit<>;

温馨提示

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

评论

0/150

提交评论