Launch an app with a message

This example sends the application name through the chat software to open the corresponding application.

Programming language: JS

Steps

1. Print out which app sent the message

2. Print out specific message content

3. Process information based on received message characteristics for effective content

4. Start the corresponding application according to the content of the message

5. Set message filtering for message content as 'camera'

6. Set the listener, when the corresponding message is received, the corresponding callback function will be started, and the corresponding application will be started.

Source code

/*
 * version : 6.2.0.2886
 * resolution : 720*1280
 * description : Sends the application name through the chat software to open the corresponding application
 */
define("version", "6.2.0.2886");
define("resolution", "720*1280");

define("requireVersion", "1.5.0.2865");

//Print out which app is sent, and the content of the message, and launch the app based on the message content
function runApp(dev, app, text) {
	//Print out which app sent the message
	print(app)
	//Print out specific message content
	print(text)	
	//Process information based on received message characteristics for effective content
	var textToArray = text.split(': ')
	print(textToArray[1]);
	//Start the corresponding application according to the content of the message
	if(textToArray[1]=="settings"){
		dev.runApp("com.android.settings");
	}
	if(textToArray[1]=="camera"){
		dev.runApp("com.android.camera");
	}	
	if(textToArray[1]=="contacts"){
		dev.runApp("com.android.contacts");
	}	
	if(textToArray[1]=="mms"){
		dev.runApp("com.android.mms");
	}	
}

var device = Device.searchObject(sigmaConst.DevSelectOne);

//Set message filtering for message content as 'camera'
var notification = new Notification(device, sigmaConst.Any,sigmaConst.Any);
//Set the listener, when the corresponding message is received, the corresponding callback function will be started, and the corresponding application will be started.
notification.setListener(runApp);