I am new in the android studio. I am working on my college project and i made this sample app to make a call because i want this function in my app. but there seems to be a problem. It says me to ask the permission to call from the user first and i m unknown how to do it. can anybody help me on this ?
This is the java code. MainActivity.java
package example.call;
import android.content.Intent;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class MainActivity extends AppCompatActivity {
private Button button;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
button = (Button)findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent callIntent = new Intent(Intent.ACTION_CALL, Uri.parse("197"));
startActivity(callIntent);
}
});
}
}
This is what I get in the error: