Android 为什么我会收到“不幸的是拨号器停止工作”?
当我运行下面的代码时,我看到不幸的是拨号器已经停止工作 以下是我的代码片段: DialerActivity.javaAndroid 为什么我会收到“不幸的是拨号器停止工作”?,android,android-layout,android-emulator,android-widget,Android,Android Layout,Android Emulator,Android Widget,当我运行下面的代码时,我看到不幸的是拨号器已经停止工作 以下是我的代码片段: DialerActivity.java package com.test; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.net.Uri; import android.widget.Button; import android.view.*; public
package com.test;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.net.Uri;
import android.widget.Button;
import android.view.*;
public class DialerActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button callButton=(Button) findViewById(R.id.callButton);
callButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v)
{
try {
Intent CallIntent =
new Intent(Intent.ACTION_CALL,Uri.parse("tel:9563460376"));
CallIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(CallIntent);
}
catch(Exception e)
{
}
}
});
}
}
main.xml
<?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" >
<button android:id="@+id/callButton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="ShowDialer"
android:background="#d3d3d3">
</button>
</LinearLayout>
string.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hell">sanjoy</string>
<string name="app_name">Test</string>
<string name="button">ShowDialer</string>
</resources>
为什么会发生这种情况
Intent serviceIntent = new Intent(context, YourClass.class);
serviceIntent.setAction("android.intent.action.NEW_OUTGOING_CALL");
serviceIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(serviceIntent);
试试这个,别忘了在清单中添加权限。您是否在应用程序中添加了呼叫权限?请在将问题发布到任何论坛之前:是的,我添加了呼叫权限呼叫按钮,在这里输入大写代码