Run Application in background


Last Updated:

  1. Ganesh

    Ganesh Member This Topic's Starter

    Joined:
    Dec 25, 2009
    Messages:
    18
    Likes Received:
    0
    Hello Friends,

    I want to develope a project in which if SIM card is changed, then messages should be sent from new SIM card to a predefined number. User should not know that the SMS are being send from his mobile. So the application needs to run in back ground. How can I achieve this?

    Thank you in regards
     

    Advertisement
  2. eclipsed4utoo

    eclipsed4utoo Well-Known Member

    Joined:
    Nov 12, 2009
    Messages:
    435
    Likes Received:
    27
    I'm sorry, but this sounds like a horrible application. You want to send a SMS message from a user's phone to a number, but you don't want the user to know about it? That sounds really sneaky.
     
  3. 28064212

    28064212 Well-Known Member

    Joined:
    Dec 14, 2009
    Messages:
    245
    Likes Received:
    17
    In fairness, it sounds more like a security app e.g. if the phone is ever stolen. I assume he means that the new user can't know anything about it, but it will be clear to the person who installed the app, and they will be the one's who set up what number the message is sent to
     
  4. eclipsed4utoo

    eclipsed4utoo Well-Known Member

    Joined:
    Nov 12, 2009
    Messages:
    435
    Likes Received:
    27
    that's the big "if". is the number hardcoded? or configurable by the installing user?
     
  5. Ganesh

    Ganesh Member This Topic's Starter

    Joined:
    Dec 25, 2009
    Messages:
    18
    Likes Received:
    0
    Hello Friends,


    I want to develope the security application in which The installer of application will set any number as reporting number. Then if the phone is stolen and used with another SIM card then the application should send SMS from this new SIM (without informing the new User [Thief]). So this application should run in back ground. Sorry to post confusing discription of my application in my first query.


    Thank you in advance
     
  6. Ganesh

    Ganesh Member This Topic's Starter

    Joined:
    Dec 25, 2009
    Messages:
    18
    Likes Received:
    0
    Hello Friends,

    I tried with the use of Service. but it does not worked. I checked logcat (thanks to ecliped4utoo; he taught me how to check logcat) but I found that my application is not going inside the Service class

    My Activity class is as follows










    import android.app.Activity;
    import android.content.Intent;
    import android.os.Bundle;
    import android.util.Log;
    import android.view.View;
    import android.view.animation.Animation;
    import android.view.animation.AnimationUtils;
    import android.widget.Button;
    import android.widget.LinearLayout;
    public class MSMAndroid extends Activity {
    private static final String TAG = "MSMAndroid";
    /** Called when the activity is first created. */
    Button btn_StartMSM;
    LinearLayout layout;
    LinearLayout layMain;

    @Override

    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    btn_StartMSM =new Button(this);
    btn_StartMSM.setText("Button");
    layout = new LinearLayout(this);
    layMain= new LinearLayout(this);
    layout.addView(btn_StartMSM);
    setContentView(layout);


    btn_StartMSM.setOnClickListener(new View.OnClickListener() {
    public void onClick(View v) {

    Intent int1 = new Intent( );
    startService(int1 );

    //Intent int = new Intent( this, MyService.class );
    //startService(int );
    //Intent a1 =new Intent(MSMAndroid.this,MSMService.class);
    //startService(a1);
    //Animation anim = AnimationUtils.loadAnimation(MSMAndroid.this, 1);
    //MSMAndroid.this.layMain.startAnimation(anim);
    //startService();
    }
    });
    }
    public void startService ()
    {
    Intent serviceIntent = new Intent(this, MSMService.class);
    Log.d(TAG, "Start service");
    startService(serviceIntent);
    btn_StartMSM.setText("After Start");
    }


    }









    My service class is

    package com.MSMAndroid;
    import android.app.PendingIntent;
    import android.app.Service;
    import android.content.Intent;
    import android.os.IBinder;
    import android.telephony.gsm.SmsManager;
    import android.widget.LinearLayout;
    public class MSMService extends Service{
    MSMAndroid msmAndroid;
    SmsManager smsManager;
    PendingIntent i1;
    LinearLayout layout2;
    String destAddr = "919860650337", mMessageText =
    "Welcome to MSMAndroid";
    @Override
    public IBinder onBind(Intent intent) {
    // TODO Auto-generated method stub
    return null;
    }
    @Override
    public void onCreate() {
    // TODO Auto-generated method stub
    super.onCreate();
    msmAndroid = new MSMAndroid();
    smsManager =SmsManager.getDefault();
    layout2 = new LinearLayout(this);
    i1 = PendingIntent.getBroadcast(this, 0, new Intent(), 0);
    //destAddr=""+phonenumber.getText();
    smsManager.sendTextMessage(destAddr, null, mMessageText, i1, null);
    msmAndroid.btn_StartMSM.setText("HERE");
    msmAndroid.setContentView(msmAndroid.layout);
    //msmAndroid.setContentView(layout2);
    //setForeground(true);



    }
    public void onStart(final Intent intent, final int startId) {
    super.onStart(intent, startId);

    }


    }


    My AndroidMenifest is


    <?​
    xmlversion="1.0"encoding="utf-8"?>
    <
    manifestxmlns:android="http://schemas.android.com/apk/res/android"

    package="com.MSMAndroid"

    android:versionCode="1"

    android:versionName="1.0">

    <applicationandroid:icon="@drawable/icon"android:label="@string/app_name"android:debuggable="true">

    <activityandroid:name=".MSMAndroid"

    android:label="@string/app_name">

    <serviceandroid:name=".MSMService"/>

    <intent-filter>

    <actionandroid:name="android.intent.action.MAIN"/>

    <categoryandroid:name="android.intent.category.LAUNCHER"/>

    </intent-filter>

    </activity>


    </application>

    <uses-sdkandroid:minSdkVersion="2"/>
    <
    uses-permissionandroid:name="android.permission.SEND_SMS"></uses-permission>

    </
    manifest>

    My R.java is as follows


    /* AUTO-GENERATED FILE. DO NOT MODIFY.
    *
    * This class was automatically generated by the
    * aapt tool from the resource data it found. It
    * should not be modified by hand.
    */
    package com.MSMAndroid;
    public final class R {
    public static final class attr {
    }
    public static final class drawable {
    public static final int icon=0x7f020000;
    }
    public static final class layout {
    public static final int main=0x7f030000;
    }
    public static final class string {
    public static final int app_name=0x7f040001;
    public static final int hello=0x7f040000;
    }
    }



    I am not getting where I am commiting the mistake


    Thank you in advance
     
  7. eclipsed4utoo

    eclipsed4utoo Well-Known Member

    Joined:
    Nov 12, 2009
    Messages:
    435
    Likes Received:
    27
    use the code tags. it properly formats the text so it's easier to read.

    you can use them like this....

    [ code]

    [/code]

    remove the space before the first "code", and you will get this...

    Code (Text):
    1.  
    2. // just copied your code
    3. public void onCreate(Bundle savedInstanceState) {
    4.       super.onCreate(savedInstanceState);
    5.       btn_StartMSM =new Button(this);
    6.       btn_StartMSM.setText("Button");
    7.       layout = new LinearLayout(this);
    8.       layMain= new LinearLayout(this);
    9.       layout.addView(btn_StartMSM);
    10.       setContentView(layout);
    11. }
    12.  
     

Share This Page

Loading...