Implicit intent to call a number

By ukmodak | March 31st 2024 10:30:09 AM | viewed 819 times

create a main.xml layout and Add a button to call implicit intent in the location: layout(android studio)

<?xml version="1.0" encoding="utf-8"? >
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" >


        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="426dp" >

            <TextView
                android:id="@+id/textView1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentTop="true"
                android:layout_centerHorizontal="true"
                android:text="Welcome to main activity "
                android:textColor="#ffffff"
                android:textSize="15sp" />

           <Button
                android:id="@+id/btn_intent_implicit"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignBaseline="@+id/btnListView"
                android:layout_alignBottom="@+id/btnListView"
                android:layout_alignRight="@+id/textView1"
                android:text="Intent(implicit)"
                android:textSize="8sp" />
          

        </RelativeLayout>

    </LinearLayout>

</LinearLayout>

create a ProjectonOverallClassMainActivity to call a phone using implicit intent

package com.uk.modak;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

public class ProjectonOverallClassMainActivity extends Activity {
   
	
	private Button call;
		
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
               
        call = (Button) findViewById(R.id.btn_intent_implicit);         
         call.setOnClickListener(new View.OnClickListener() {
			
			public void onClick(View v) {
				
				Intent callIntent = new Intent(Intent.ACTION_CALL);
				
				callIntent.setData(Uri.parse("tel:01822210098"));
				
				startActivity(callIntent);			
				
			}
		});                    
    }
    
    public void onStart(){
    	super.onStart();
    	 	
    }
      
    
}

Go to menifeast and setup activity that we use

<application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:name=".ProjectonOverallClassMainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
       
        <activity
            android:name=".ImplicitIntentHomeActivity"
            android:label="@string/app_name" >
           
        </activity>
        
        <receiver android:name=".ConnectionReceive">
            <intent-filter>
                <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
            </intent-filter>
        </receiver>
        
    </application>

Go to menifeast and setup phone permission

 <uses-permission android:name="android.permission.CALL_PHONE">
bONEandALL
Visitor

Total : 26654

Today :3

Today Visit Country :

  • France
  • United States