_FaKe SMS

  1. package be.yakupkalin.fakesms;


  2. import android.app.Activity;

  3. import android.content.ContentValues;

  4. import android.net.Uri;

  5. import android.os.Bundle;

  6. import android.view.View;

  7. import android.view.View.OnClickListener;

  8. import android.widget.ArrayAdapter;

  9. import android.widget.Button;

  10. import android.widget.Spinner;

  11. import android.widget.TextView;


  12. public class Main extends Activity {


  13. private Button btnSave, btnStatus;

  14. private Spinner spFrom;

  15. private TextView txtBody;

  16. private String from = "Ghost";


  17. @Override

  18. public void onCreate(Bundle savedInstanceState) {

  19. super.onCreate(savedInstanceState);

  20. setContentView(R.layout.main);


  21. btnSave = (Button)findViewById(R.id.btnSave);

  22. btnStatus = (Button)findViewById(R.id.btnStatus);

  23. spFrom = (Spinner)findViewById(R.id.spFrom);

  24. txtBody = (TextView)findViewById(R.id.etBody);


  25. String[] arFrom = getResources().getStringArray(R.array.fromStrings);

  26. java.util.Arrays.sort(arFrom);


  27. ArrayAdapter adapter = new ArrayAdapter(this,

  28. android.R.layout.simple_spinner_item, arFrom);


  29. spFrom.setAdapter(adapter);

  30. btnStatus.setOnClickListener(new OnClickListener() {


  31. @Override

  32. public void onClick(View v) {

  33. btnStatus.setVisibility(View.INVISIBLE);

  34. }

  35. });

  36. btnSave.setOnClickListener(new OnClickListener() {

  37. @Override

  38. public void onClick(View v) {

  39. saveSMS(spFrom.getSelectedItem().toString(), txtBody.getText().toString());

  40. }

  41. });

  42. }


  43. private void saveSMS(String from, String body) {

  44. ContentValues values = new ContentValues();

  45. values.put("address", from);

  46. values.put("body", body);

  47. getContentResolver().insert(Uri.parse("content://sms/inbox"), values);

  48. btnStatus.setText("Message Sent! (close)");

  49. btnStatus.setVisibility(View.VISIBLE);

  50. }

  51. }

Chú Ý:

Coppy phải ghi rõ nguồn Blog - Hacking
 

Copyright © 123 H4ck' Blog. Cung cấp bởi Blogger