即时通讯设法使用按钮调用不同的电话号码的应用程序。我有这个: package com.BigTooth.Apps.Recromax;如何从Android应用程序拨打电话
import android.app.*;
import android.os.*;
import android.view.*;
import android.widget.*;
import android.content.Intent;
import android.content.*;
import android.net.Uri;
import android.view.View.OnClickListener;
public class MainActivity extends Activity
{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
private void phoneCall1()
{
String phoneCallUri = "tel:4078421430";
Intent phoneCallIntent = new Intent(Intent.ACTION_CALL);
phoneCallIntent.setData(Uri.parse(phoneCallUri));
startActivity(phoneCallIntent);
}
// add button listener
button.setOnClickListener(new OnClickListener() {
private void phoneCall()
{
String phoneCallUri = "tel:8889807091";
Intent phoneCallIntent = new Intent(Intent.ACTION_CALL);
phoneCallIntent.setData(Uri.parse(phoneCallUri));
startActivity(phoneCallIntent);}
}
}
在我的MainActivity.java文件中。它告诉我这是不正确的。请帮忙!!!
请发布Logcat输出。另外,您的Manifest中是否有'CALL_PRIVILEGED'权限? – OrhanC1
你的'button.setOnClickListener'在任何函数之外..在错误的范围..把它放在onCreate ..和phoneCall函数也是太乱..太多的copypaste ..试着学习一些基本知识之前开始copypaste :) – Hardy
我确实有我的清单中的权限 – tycemang