Android Fake SMS in Eclipse

In this post you will learn to make a fake sms android app using java. You can use this app for duplicating messages, playing prank with friends etc.I am not  responsible for the wrong use of this application in any manner :P.

NUTSHELL :-

  • The main java code used here is
ContentValues my_values = new ContentValues(); // hold the message details
my_values.put("address",num);//sender name
my_values.put("body", body);
my_values.put("read", 0);
...

String path="content://sms/inbox";
getContentResolver().insert(Uri.parse(path), my_values);
  • We must also add the following permission to AndroidManifest

 

<uses-permission android:name="android.permission.WRITE_SMS"></uses-permission>
<uses-permission android:name="android.permission.READ_SMS"></uses-permission>

 

[wpi_designer_button text=’Download’ link=’https://github.com/arjunsk/Fakesms&#8217; style_id=’48’ icon=’github’ target=’_blank’]

LEVEL 2 [Intermediate] :

  1. MainActivity.java
import java.text.SimpleDateFormat;
import java.util.Calendar;
import android.app.Activity;
import android.content.ContentValues;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.WebView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.TimePicker;
import android.widget.Toast;

public class FakesmsActivity extends Activity {
private String array_spinner[];

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

// Options  that you wish to put your fake message in
array_spinner=new String[5];
array_spinner[0]="inbox";
array_spinner[1]="sent";
array_spinner[2]="draft";
array_spinner[3]="outbox";
array_spinner[4]="failed";
final Spinner s = (Spinner) findViewById(R.id.spinner1);

//Setting Array adapter to the spinner
ArrayAdapter adapter = new ArrayAdapter(this,
android.R.layout.simple_spinner_item, array_spinner);
s.setAdapter(adapter);

//intialising the layout elements
final EditText tnum;
final EditText tbody;
final TimePicker tp;
final DatePicker dp;
Button save,reset;

//maping the layout elements
tnum = (EditText) findViewById(R.id.tnum);
tbody= (EditText) findViewById(R.id.tbody);
save = (Button) findViewById(R.id.save);
reset=(Button) findViewById(R.id.reset);
tp=(TimePicker)findViewById(R.id.timePicker1);
dp=(DatePicker)findViewById(R.id.datePicker1);

save.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {

String num=tnum.getText().toString();
String body=tbody.getText().toString();

// my_values object holds the user input values.

ContentValues my_values = new ContentValues();
my_values.put("address",num);//sender name
my_values.put("body", body);

//set read to 0 to show the message as unread.
my_values.put("read", 0);

//for date
Calendar cal = Calendar.getInstance();
cal.set(dp.getYear(), dp.getMonth(), dp.getDayOfMonth());

//for time
cal.set(Calendar.HOUR_OF_DAY,tp.getCurrentHour());
cal.set(Calendar.MINUTE,tp.getCurrentMinute());
cal.set(Calendar.SECOND,0);

//inserting the date and time into my_values
my_values.put("date", cal.getTimeInMillis());

//the path is generated based on the spinner selection
String path="content://sms/"+array_spinner[s.getSelectedItemPosition()];

if( getContentResolver().insert(Uri.parse(path), my_values)!=null){

Toast.makeText(getBaseContext(), "Successfully Faked!",Toast.LENGTH_SHORT).show();
//for a bug
getContentResolver().delete(Uri.parse("content://sms/conversations/-1"), null, null);
}

else
Toast.makeText(getBaseContext(), "Unsuccesful!",Toast.LENGTH_SHORT).show();

}
});

reset.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {
// TODO Auto-generated method stub

tnum.setText("");
tbody.setText("");

}
});

}

}

 

2. The layout xml

<?xml version="1.0" encoding="utf-8"?>

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>

<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Sender Phone Number/Name" />
<EditText
android:id="@+id/tnum"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="text" />
</LinearLayout>

<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Message Body" />
<EditText
android:id="@+id/tbody"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:ems="10"
android:minLines="4"
android:gravity="top"
android:inputType="textMultiLine" />
</LinearLayout>

<Spinner
android:id="@+id/spinner1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>

<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Pick your time" />
<TimePicker
android:id="@+id/timePicker1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Pick your date" />
<DatePicker
android:id="@+id/datePicker1"
android:calendarViewShown="false"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />

<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:text="Sksoft Productions!"
android:textAppearance="?android:attr/textAppearanceSmall" />

</LinearLayout>

<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="2" >
<Button
android:id="@+id/save"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="Save" />
<Button
android:id="@+id/reset"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="Reset" />
</LinearLayout>

</LinearLayout>

</ScrollView>

3. Android Manifest

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.tricks4speed.fakesms"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk android:minSdkVersion="15" />
<uses-permission android:name="android.permission.WRITE_SMS"></uses-permission>
<uses-permission android:name="android.permission.READ_SMS"></uses-permission>

<application
android:icon="@drawable/logo"
android:label="FAKE SMS" >
<activity
android:name=".FakesmsActivity"
android:label="Fake sms" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s