ActivityManager: Warning: Activity not started, it

Java Code:

package com.example.phone5; import android.app.Activity; import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.view.Menu; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.EditText; public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Button callBT = (Button) findViewById(R.id.callBT); callBT.setOnClickListener(new MyOnClickListener()); } public class MyOnClickListener implements OnClickListener { public void onClick(View v) { // 找到文本框 EditText GetNum = (EditText) findViewById(R.id.GetNum); // 从文本框里面获取号码 String num = GetNum.getText().toString(); // 建立意图对象 Intent intent = new Intent(); // 设定打电话这个动做 intent.setAction(Intent.ACTION_CALL); // 设定获取电话号码 intent.setData(Uri.parse("tel:" + num)); startActivity(intent); } } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } }






XML Code

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/Number" />

    <EditText
        android:id="@+id/GetNum"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" />

    <Button
        android:id="@+id/callBT"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/call" />

</LinearLayout>



在编写一个Phone Application程序的时候出现了一个问题:console显示,ActivityManager: Warning: Activity not started, its current task has been brought to the front java

解决思路:百度(有了问题本身分析考虑事后没找到思路问百度) 也就是在修改了代码后,在没有从新编译这步, 模拟器原来的.apk就不会通过卸载跟从新安装这一步;因此当在eclipse中只是点击运行时,因为如今的程序没有通过编译这一步,因此安装的程序跟原来的同样, 因此在console输出的信息中会出现这一行信息: ActivityManager: Warning: Activity not started, its current task has been brought to the front  android

      但在调式的时候发现,这样作能够解决这个问题;首先在Package Explorer中找到要运行的程序,而后点击右键,选中 refresh, 而后再选中run as -----> android application,最后解决了问题; app


可是当输入完电话号码,拨打的时候程序报错以下:

LogCat显示: eclipse

 threadid=1: thread exiting with uncaught exception (group=0x40015560)FATAL EXCEPTION: main ide

android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.CALL dat=tel:1233453 } oop

at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1409)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1379)
at android.app.Activity.startActivityForResult(Activity.java:2827)
at android.app.Activity.startActivity(Activity.java:2933)
at com.example.phone5.MainActivity$MyOnClickListener.onClick(MainActivity.java:36)
at android.view.View.performClick(View.java:2485)
at android.view.View$PerformClick.run(View.java:9080)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:3683)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
12-12 08:50:47.134: I/Process(589): Sending signal. PID: 589 SIG: 9
this

通过对Logcat的分析能够发现问题出如今这里:(tel:这个标点有问题不是英文标点 spa

android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.CALL dat=tel:1233453 } .net

总结:

1.最好所有用英文来写整个程序,不要中英文来回切换,真的要写中文的注释,最好集中写。
2.学会看LogCat本身找问题出如今哪里(这是的问题)

相关文章
相关标签/搜索