View difference between Paste ID: JSB1tKFQ and atjSWFEf
SHOW: | | - or go back to the newest paste.
1
import android.app.Activity;
2
import android.content.ActivityNotFoundException;
3
import android.content.Intent;
4
import android.net.Uri;
5
import android.os.Bundle;
6
import android.util.Log;
7
8
9
public class phonecalls extends Activity {
10
    /** Called when the activity is first created. */
11
    @Override
12
    public void onCreate(Bundle savedInstanceState) {
13
        super.onCreate(savedInstanceState);
14-
        call();
14+
15
        try {
16
			call();
17-
private void call() {
17+
		} catch (InterruptedException e) {
18
			// TODO Auto-generated catch block
19
			e.printStackTrace();
20
		}
21
    }
22
23
private void call() throws InterruptedException {
24
    try {
25
        Intent callIntent = new Intent(Intent.ACTION_CALL);
26
        callIntent.setData(Uri.parse("tel:575757570089"));
27
        startActivity(callIntent);
28
        //Thread.sleep(5000);
29
        orij();
30
        
31
    } catch (ActivityNotFoundException activityException) {
32
        Log.e("dialing-example", "Call failed", activityException);
33
    }
34
}
35
36
private void orij() {
37
	// TODO Auto-generated method stub
38
	 Intent intent = new Intent(this, OutgoingCallReceiver.class);////For calling reciever class
39
	 startActivity(intent);
40
}
41
42
}
43
44
45
46
RECIEVER CLASS:
47
import android.content.BroadcastReceiver;
48
import android.content.Context;
49
import android.content.Intent;
50
import android.util.Log;
51
import android.widget.Toast;
52
53
public class OutgoingCallReceiver extends BroadcastReceiver {
54
55
	@Override
56
	public void onReceive(Context context, Intent intent) {
57
		// TODO Auto-generated method stub
58
		if(intent.getAction().equals(Intent.ACTION_NEW_OUTGOING_CALL))
59
	     {
60
	       abortBroadcast ();
61
	       }	
62
	}
63
	
64
}