PhoneFinder--寻找丢失的手机

    手机丢了怎么办?那就打电话给手机,如果运气好的话,捡到的好心人能够把手机还给你。如果手机是被偷的,那就没有办法了,即使手机开着,估计小偷也不会接电话。当然,我们继续下面讨论的前提就是:手机是掉了,而且被好心人捡到,但是他不知道怎么还;或者是手机处在silent状态,你打电话人家听不到。Googlepage上有这么一个类似的应用,也叫PhoneFinder,不过这个软件是要收钱的。在windows mobile 6 SDK自带的例子中,有一个PhoneFinder的应用,通过它,你可以在手机上设置一定的信息,如果你通过SMS,发送这个信息到手机上,手机就会弹出提示框,显示主人的信息,同时播放一段声音,以引起注意。

    开发这样的应用程序,我们首先需要了解一下几方面的内容:

1. State and Notifications Broker API

2. Pocket Outlook Object Model Application Development for Windows Mobile-based Devices

3. MessageInterceptor

    在应用程序的主界面上,我们可以让用户输入信息内容,并且设置应用是否允许。这样,在设备接收到含有预先设定的短信之后,就会做出相应的动作,如弹出提示框,播放声音等等。其中,开启短信拦截的关键代码段如下:

ContractedBlock.gif ExpandedBlockStart.gif Code
interceptor = new MessageInterceptor(InterceptionAction.NotifyAndDelete);

interceptor.MessageCondition 
= new MessageCondition();

interceptor.MessageCondition.CaseSensitive 
= true;

interceptor.MessageCondition.ComparisonType 
= MessagePropertyComparisonType.Equal;

interceptor.MessageCondition.ComparisonValue 
= pin.Text;

interceptor.MessageCondition.Property 
= MessageProperty.Body;

interceptor.EnableApplicationLauncher(ruleName);

     播放声音使用PlaySound方法,通过PInvoke得到:

ContractedBlock.gif ExpandedBlockStart.gif Code
ContractedBlock.gifExpandedBlockStart.gifPlaySound#region PlaySound

[System.Runtime.InteropServices.DllImport(
"coredll.dll")]

static extern int PlaySound(string pszSound, IntPtr hMod, int fdwSound);

const int SND_FILENAME = 0x20000;

const int SND_SYNC = 0x0;

const int SND_ASYNC = 0x1;

const int SND_LOOP = 0x8;

#endregion

 主人信息通过SystemState获得:

ContractedBlock.gif ExpandedBlockStart.gif Code
string owner = SystemState.OwnerName;

string email = SystemState.OwnerEmail;

string phone = SystemState.OwnerPhoneNumber;

 

    测试这个应用程序我们可以使用Device EmulatorCellular Emulator。首先,打开设备模拟器和蜂窝模拟器,并将它们建立联系,具体步骤参考《Ring Tone Manager on Windows Mobile》。然后将程序部署到设备进行调试。调试时,应用程序的主界面如下图1所示:

1:应用程序主界面

    在Pintext中设置好相应的文字以后,点击“Enabled”,启动短信拦截,然后点击左下方的Exit退出界面。这时候,我们在蜂窝模拟器里面给设备模拟器发送字符串“1234”,如下图2所示:

2:蜂窝模拟器中的SMS发送界面

    这时候,我们就可以在设备模拟器中看到相应的消息框,并听到声音了。如下图3所示:

3:设备模拟器中看到的提示消息框

参考链接:

GooglePhoneFinder

MSDN

1. State and Notifications Broker API

2. Pocket Outlook Object Model Application Development for Windows Mobile-based Devices

3. MessageInterceptor

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值