The phone has a new text message, remind me via computer

Source: Internet
Author: User

Generally I use mobile phone less time, with more computer time, mobile phone light users, the computer is heavy, work or go home after work is basically in the computer, so often there will be a mobile phone is not at hand or charging the situation, listen to the song is Hi mobile phone to the phone or to SMS the basic rarely will detect, To the phone is good to say that the text message will vibrate once, and so you go to use the phone when it may have been a long time, I think if the phone has a text message can be directly through the computer to tell me not to better, so do not miss, so I want to have a new mobile phone message on the computer reminds me of such a feature.

Then check to see if there are any such software, found that there are a few can achieve this demand, but a bit more features, is a software inside one of the features.

Finally decided to write a function, one is because I still like the function of a little bit, the second is to read the text message this function or more dangerous, the other people's software is not assured that their own write the total trust it, at least what they have to know.

The final function after the implementation of the situation is that the phone has a new text message, in my notebook to play a window to tell me on the line.

Thought to realize the process should be the mobile phone has a program, to achieve the function of receiving text messages and receive text messages to the text message and send the sender to my computer, the computer received, the bottom right corner of the window. That's all.

The premise is that the mobile network and the computer network are in the same network

Approximate flowchart

Step by step to do, the window function is very good, is a WinForm program, the above two tags, a title of a content, has already been, can be used directly, when the launch of two parameters in the past will show what you came.

Then is the phone how to send messages to the computer, the implementation method is also many, with TCP or UDP, write a program on the computer to listen to the port, the mobile app directly to the hair.

But I write a lot of work, I still like to use it, and now the system is generally self-brought IIS server, but also boot automatically start, for their own is almost no special to the state of the tube. In this way, directly on the IIS set up a site, write a dynamic page, there is a request to open the pop-up window program can be, the mobile app can directly put data to this page post, the page and then open the pop-up window program, I feel very ok.

Then there is the problem with the mobile app, how the app receives a text message, and then how to post data to the computer.

Android system has a message broadcast function, when there is a new text message will be issued a broadcast, you can write a message broadcast receiver, there is a new message when the system will call your broadcast receiver, and then you can get the message content, and then you can use the HTTP function of the content to the computer sent, So the overall process is the following.

Just follow this idea, step on a lot of pits, and then some key parts of the code

1, create a new Android project

Set permissions to get related

 <uses-permissionAndroid:name= "Android.permission.INTERNET" />    <uses-permissionAndroid:name= "Android.permission.RECEIVE_SMS" />    <uses-permissionAndroid:name= "Android.permission.READ_SMS" />    <uses-permissionAndroid:name= "Android.permission.RECEIVE_BOOT_COMPLETED" />

New SMS Broadcast Receiver

  <receiverAndroid:name=". Smsrecever ">            <Intent-filterandroid:priority= "+">                <ActionAndroid:name= "Android.provider.Telephony.SMS_RECEIVED" />            </Intent-filter>        </receiver>

Get SMS content and send to PC

 Public classSmsreceverextendsBroadcastreceiver {@Override Public voidOnReceive (Context context, Intent Intent) {FinalString URL =Datahelper.geturl (context); if("". Equals (URL)) {            return; } Bundle Bundle=Intent.getextras (); Object[] Objects= (object[]) bundle.get ("PDUs"));  for(Object obj:objects) {smsmessage smsmessage= SMSMESSAGE.CREATEFROMPDU ((byte[]) obj); //get the content of a text message            FinalString BODY =Smsmessage.getdisplaymessagebody (); //get the sender of a text message            FinalString address =smsmessage.getdisplayoriginatingaddress (); //time to get text messages            LongDate =Smsmessage.gettimestampmillis (); SimpleDateFormat format=NewSimpleDateFormat ("Yyyy-mm-dd hh:mm:ss"); Format.settimezone (Timezone.gettimezone ("Gmt+8")); FinalString Datestr =Format.format (date); NewThread (NewRunnable () {@Override Public voidRun () {common. Sendmsg (URL, address, body+ "[" + Datestr + "]");        }}). Start (); }    }}

2, set up a Web site to receive SMS content

Add an ASPX page

     Public Partial classShowmsg:System.Web.UI.Page {protected voidPage_Load (Objectsender, EventArgs e) {            //accept title and content parameters            stringMM = Httputility.urlencode (request["T"]) +" "+ Httputility.urlencode (request["b"]); //Open EXE program_processutil.createprocessasuser (@"E:\codeProjects\Projects\showmsg\msg\bin\Debug\msg.exe", MM, _processutil._session_type.            Sessionfromactiveconsolesessionid); Response.Write ("1"); }    }

Microsoft in the Vista system after a session of the isolation mechanism, IIS is a background service, belongs to session 0 level, different sessions can not be sent through the window to each other, so use in C # System.Diagnostics.Process.Start directly call EXE, you can not see the interface.

Check the workaround, you can call a system API method CreateProcessAsUser to create the process.

Finally the perfect post-effect app interface is this

Pop-up window program

The phone has a new text message, remind me via computer

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.