sms= app.CreateSMS();
sms.OnMessage(receive)
//I don't know exactly how it works. Try it out
function receive(msg) {
alert(msg)
//alert(msg).GetText();
}
If you are interested in doing this yourself, I would recommend using the AIDE app on android to create the plugin.
The premium version of DroidScript comes with an sdk entry in the main menu to get started but if you do not have a Premium subscription, you can still access it.
You can get that menu as a non-premium user by creating a file called _sdk_ (with no extension) in your DroidScript folder on your phone or tablet.
If you can find a cordova/phonegap plugin that does what you want, it would be a good start for building a DS plugin.
If this is not something you want to tackle yourself,it may be worth asking a Java developer to turn it into a DS plugin.
Or you might consider sponsoring the DS team to create a DS plugin from the phonegap plugin you have found to share with the community.
If you wish to ask a private Java programmer to develop the plugin and she does not wish to use AIDE, the sdk is also available for Eclipse. http://androidscript.org/sdk/
package com.mycompany.myapp;
import android.app.*;import android.os.*;
// ***************************// MZH imports// ***************************
//import My_Java_Procedures.*;
import android.content.*;import android.util.Log;import android.graphics.*;import java.io.*;import java.lang.reflect.*;
// For sms//import android.app.Activity;import android.content.ContentResolver;import android.database.Cursor;import android.net.Uri;//import android.os.Bundle;//import android.view.View;//import android.view.View.OnClickListener;//import android.widget.Button;//import android.widget.ListView;import android.widget.SimpleCursorAdapter;//import android.widget.TextView;
// ***************************public class MainActivity extends Activity { //public static final String TAG = "Basic Network Demo"; // MZH //private static boolean wifiConnected = false; // MZH
// Global variables //private static int Result; // It is important to have the static keywork in front //private static String ResultString;
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Log.d("MyApp","Start my App - Launch go"); go(1); // MZH }
// ***************************// My Code start here // ***************************
public static void go(int k) { // Local Variables int Result; String ResultString;
Result = My_Java_Procedure_Call(7); ResultString = "" + Result; Log.d("MyApp",ResultString); ResultString = Read_SMS_Inbox(1); Log.d("MyApp",ResultString); }
public int My_Java_Procedure_Call(int n) { Log.d("MyApp","Procedure Call successful"); return n*2; }
// Permissions in AndroidMenifest.xml file <uses-permission android:name="android.permission.READ_SMS"></uses-permission>
public static String Read_SMS_Inbox(int MessageNumber) { // Create Inbox box URIUri inboxURI = Uri.parse("content://sms/inbox"); // List required columnsString[] reqCols = new String[] { "_id", "address", "body" }; // Get Content Resolver object, which will deal with Content ProviderContentResolver cr = getContentResolver(); // Fetch Inbox SMS Message from Built-in Content ProviderCursor c = cr.query(inboxURI, reqCols, null, null, null);
adapter = new SimpleCursorAdapter(this, R.layout.row, c, new String[] { "body", "address" }, new int[] { R.id.lblMsg, R.id.lblNumber }); return adaptor; // *************************** }
}
Beware! This does not work in the current release of DroidScript.
I suppose it would be worth considering the following missing permissions
WRITE_CONTACTS
READ_SMS
WRITE_SMS