In this post you will learn how to create an android app which will scream aloud no mater if the mobile is in silent or in general mode. This will work even if the app isnt in the open state. The screaming gets triggered when someone sends “scream” to your mobile as SMS. That is basically the hot word for triggering the screaming sound.
The Code:
The SMSReciever Broadcast Class:
public class RecieveSMS extends BroadcastReceiver
{
public static final String SMS_BUNDLE = "pdus";
MediaPlayer mp;
@Override
public void onReceive(Context context, Intent intent) {
Bundle intentExtras = intent.getExtras();
if (intentExtras != null) {
Object[] sms = (Object[]) intentExtras.get(SMS_BUNDLE);
for (int i = 0; i < sms.length; ++i) {
SmsMessage smsMessage = SmsMessage.createFromPdu((byte[]) sms[i]);
String smsBody = smsMessage.getMessageBody().toString();
if (smsBody.contains("scream") || smsBody.contains("SCREAM"))
{
for(int i1=0;i1<3;i1++)
{
mp=MediaPlayer.create(context, R.raw.plutonium);
mp.start();
// Toast.makeText(context, "Alarm....", Toast.LENGTH_LONG).show();
try {
Thread.sleep(6000);
}catch (InterruptedException e){
// TODO Auto-generated catch block
e.printStackTrace();
}
mp.stop();
}
}
Toast.makeText(context, smsBody, Toast.LENGTH_SHORT).show();
}
}
}
}
The Manifest File:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.scream.mobile"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.scream.mobile.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name=".RecieveSMS">
<intent-filter>
<action android:name="android.provider.Telephony.SMS_RECEIVED"></action>
</intent-filter>
</receiver>
</application>
<uses-permission android:name="android.permission.RECEIVE_SMS"></uses-permission>
</manifest>
There is a folder raw inside res which contains the plutonium.mp3 file which has scream output !
Alternatively you can download the complete Eclipse ADT package by clicking here !
Found Bugs ? Feel free to report them here !



Developer, Tinkere, a proud Dad.. love to spend my available time playing with Tech!!