gpt4 book ai didi

java - 为什么我的 Logcat 不显示任何日志?

转载 作者:太空狗 更新时间:2023-10-29 13:58:58 25 4
gpt4 key购买 nike

主.java

Package com.first.service;

import android.support.v7.app.ActionBarActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;

public class Main extends ActionBarActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Intent i = new Intent(this,Myservice.class);
startService(i);
}

@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;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}

MyService.java

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.util.Log;
import android.widget.TextView;

public class Myservice extends Service{
public Myservice(){

}

@Override
public IBinder onBind(Intent intent) {
// TODO Auto-generated method stub
return null;
}

@Override
public void onDestroy() {
// TODO Auto-generated method stub
super.onDestroy();
}

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
// TODO Auto-generated method stub
Log.i(TAG, "Service Started");
return Service.START_STICKY;
}

}

我是 android 服务的新手,我想创建一个新的服务应用程序,但 logcat 没有显示任何内容。

如果代码有任何问题,请帮助我并建议我。我是 StackOverflow 的新手。

看图思路清晰:

最佳答案

根据 this :Eclipse 中对 Android 开发者工具 (ADT) 的支持已经结束。您应该尽快将您的应用开发项目迁移到 Android Studio。

关于java - 为什么我的 Logcat 不显示任何日志?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37237239/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com