进程没有在android中显示

时间:2011-09-22 06:31:21

标签: android

我有一个我写的应用程序,它是以下包“com.pack”。当我启动应用程序时,我看不到DDMS中设备中显示的进程列表中的“com.pack”。怎么可能有人知道为什么?这是代码和xml清单文件。

package com.pack;

import java.util.List;

import java.util.Timer;
import java.util.TimerTask;

import android.app.Activity;
import android.content.ComponentName;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.graphics.PorterDuff.Mode;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.format.Time;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.android.internal.telephony.CallManager;
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.Call;
import com.android.internal.telephony.PhoneFactory;

public class AutoVT extends Activity {

    public static final int MAKE_CALL           = 1;

    public static final int END_CALL            = 2;

    public static final int PHONE_STATE_CHANGED = 101;

    //CallManager mCM;

    Button callButton ;

    ActivityInfo info =null; 

    ComponentName component ;

    String callperiod_text;

    String waitperiod_text;

    String number;

    public int callPeriod=0;

    public int waitPeriod = 0;

    @Override
    public void onCreate(Bundle savedInstanceState) {

        Log.i("AutoVT","starting AutoVT");

        //registerForPhoneStates();

        super.onCreate( savedInstanceState );

        setContentView( R.layout.main );

        callButton = (Button)findViewById(R.id.callButton);

        callButton.getBackground().setColorFilter(0xFFFF0000,Mode.MULTIPLY);

        callButton.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {

                callperiod_text   =  ( ( ( EditText )findViewById( R.id.call_period )).getText()).toString();

                waitperiod_text   =  ( ( ( EditText )findViewById( R.id.wait_period )).getText() ).toString();

                number =  ( ( ( EditText )findViewById( R.id.PhoneNumber )).getText() ).toString();

                if( !callperiod_text.equals("")&& !waitperiod_text.equals("") && ! number.equals("")) {

                    callPeriod = (Integer.valueOf( callperiod_text ))*1000;

                    waitPeriod = (Integer.valueOf( waitperiod_text ))*1000;

                    phoneHandler.sendEmptyMessage(MAKE_CALL);


                }

            }

        });

    }

    private Handler phoneHandler = new Handler() {

        public void handleMessage(Message msg) {

            Log.i("AutoVT received some message:", msg.toString());

            switch(msg.what) {

                case PHONE_STATE_CHANGED: {

                    Log.i("AutoVT","Phone State Changed");

                    Log.i("AutoVT", mCM.getActiveFgCallState() );

                    if( mCM.getActiveFgCallState() == Call.State.ACTIVE ) {

                        Log.i("AutoVT","Call ACTIVE");

                        final Timer timer = new Timer();

                        Log.i("AutoVT","Active timer started");

                        timer.scheduleAtFixedRate( new TimerTask() {

                            int count = 0;

                            public void run() {

                                if( count++ >=1) {

                                    timer.cancel();

                                    runOnUiThread(new Runnable() {

                                        @Override
                                        public void run() {

                                            phoneHandler.sendEmptyMessage(END_CALL);

                                        }
                                    });

                                }                               
                            }
                        }, 0, callPeriod );

                    } else if( mCM.getActiveFgCallState() == Call.State.DISCONNECTED ) {

                        Log.i("AutoVT","Call DISCONNECTED");

                        final Timer timer =new Timer();

                        Log.i("AutoVT","Waiting timer started");

                        timer.scheduleAtFixedRate( new TimerTask() {

                            int count = 0;

                            public void run() {

                                if( count++ >=1) {

                                    timer.cancel();

                                    runOnUiThread(new Runnable() {

                                        @Override
                                        public void run() {

                                            phoneHandler.sendEmptyMessage(MAKE_CALL);

                                        }
                                    });

                                }                               
                            }
                        }, 0, waitPeriod );


                    }

                    break;

                }

                case MAKE_CALL : {

                    Log.i("AutoVT","In the case MAKE_CALL");

                    Intent callIntent = new Intent(Intent.ACTION_CALL_PRIVILEGED,Uri.fromParts("tel", number,null));

                    callIntent.putExtra("videocall", true);

                    callIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP| Intent.FLAG_ACTIVITY_NEW_TASK);

                    getApplicationContext().startActivity(callIntent);

                    break;
                }

                case END_CALL :{

                    Log.i("AutoVT","In the case END_CALL");

                    Intent callEndIntent = new Intent();

                    callEndIntent.setAction("com.android.phone.END");

                    sendBroadcast(callEndIntent);

                    break;
                }

            }

        }

    };

}

XML清单

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.pack"
      android:versionCode="1"
      android:versionName="1.0">


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

    </application>
</manifest>

2 个答案:

答案 0 :(得分:1)

  1. 转到您的android-sdk/tools目录。
  2. 如果您在linux ./adb shell为您工作,请进入adb shell。
  3. fire command dumpsys activity
  4. 如果你想从eclipdse那里得到它,

     DDMS -> Devices -> select your device or Emulator -> look at that window you have find
     your current running process's package name.
    

    感谢。

答案 1 :(得分:0)

它不会处理其logcate转到Windows&gt;&gt;显示视图&gt;&gt;其他&gt;&gt;单击logcate并运行您的项目,以便显示

i think you need this

并使用

 System.out.println(); 

用于在logcate中生成消息