2012-01-19 9 views
2

質問サービスは、私は私のサービスで何が起こるか見るために少し問題を抱えてログ


表示されません。私はそれのログを取得していない。だから私はおそらく私は私のサービスを開始しないと思ったが、これは問題ではない。デバイス上で実行中のアプリケーションに移動すると、そのサービスがそこにリストされます。 )

たManifest.xml

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

    <uses-sdk android:minSdkVersion="14" /> 

    <application 
     android:icon="@drawable/ic_launcher" 
     android:label="@string/app_name" 
     android:theme="@style/Theme.IVOCore" 
     android:debuggable="true"> 

     <service android:name=".service.DataHandlerService" /> 
      <!-- android:enabled="true" 
      android:icon="@drawable/ic_launcher"/> 

     android:process=":DataHandler" --> 

     <activity 
      android:label="@string/app_name" 
      android:name=".LoginActivity" > 
      <intent-filter > 
       <action android:name="android.intent.action.MAIN" /> 
       <action android:name="de.ivocore.LOGINCHECK"/> 
       <category android:name="android.intent.category.LAUNCHER" /> 
      </intent-filter> 
     </activity> 

     <activity 
      android:name=".MainActivity"></activity>  

    </application> 


     <!-- Definieren welche Permission's die Applikation besitzt --> 
     <uses-permission android:name="android.permission.INTERNET" /> 

</manifest> 

をMainActivity.class

私はここに私のonCreate(でのサービスを開始します。

は、今のコードを見てみましょう。

package de.ivocore; 

import de.ivocore.service.DataHandlerService; 
import android.app.Activity; 
import android.content.Intent; 
import android.os.Bundle; 
import android.view.Menu; 
import android.view.MenuInflater; 

public class MainActivity extends Activity { 

    private final String LOAD_ORDER = "de.ivocore.MainActivity.LOAD_ORDER"; 

    //Verschiedene Integer definieren für Switch/Case damit der Service weis was zu tun ist 
    int FIRST_LOAD = 0; //Wird gesendet beim onCreate der Activity 
    int RELOAD = 1; //Wird gesendet wenn der User einen reload möchte 

    /** Called when the activity is first created. */ 
    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.main); 

     //Service starten zusätlich wird folgender Parameter mitgegeben "onstart" 
     //dies zeigt dem Service das die Activity gerade gestartet wurde. 
     Intent i = new Intent(this, DataHandlerService.class); 
     i.putExtra(LOAD_ORDER, FIRST_LOAD); 
     startService(i); 
    } 



    public void onReceive(Intent intent){ 

    } 
} 

DataHandlerService.class

は、ここで私は、おそらく仕事をdosn't onStartCommand()以上の意図を、キャッチ。しかし、私は...いただきました!間違って

public class DataHandlerService extends Service { 
    private AlarmManager alarmManager; 
    private Calendar calendar; 
    private static final int PERIOD = 60000 * 60; // 1h 
    private final String LOAD_VIDEO = "de.ivocore.service.DataHandlerService.LOAD_VIDEO"; 
    private final String LOAD_ORDER = "de.ivocore.MainActivity.LOAD_ORDER"; 

    LoginAdapter mDbHelper = new LoginAdapter(this); 

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


    public void onStartCommand(Intent intent, int flags, String startID){ 
     int load = intent.getIntExtra(LOAD_ORDER, 0); 
     Log.d("DataHandlerService", "Activity startet mit folgendem Parameter ="+load); 

     switch (load){ 
     case 0: 
      Log.d("DataHandlerService", "Es wird def OfficeTimerOnStart gestartet"); 
      checkOfficeTimeOnStart(); 
     break; 
     case 1: 
      getOrders(); 
     break; 
     } 



    } 

    public void onDestroy(){ 
     stopSelf(); 
    } 
} 

を得ることはありません、私は私のログを見ることができることを、私が間違ってやっているものを私に教えてください!

ありがとうございました。

よろしく

サファリ

答えて

2

DDMSロギング機能の使用に問題がある可能性があります。 ファイルシステムのファイルにログを取得し、ログを検索してみてください。

1 > Go to command prompt. 
2 > Traverse to the platform tools dir of your SDK location 
3 > type " adb logcat > D:\log.txt 

------ 
4. After starting your app exit the logcat by pressing ctrl+c 

ログの存在を確認してください。

1

あなたは、デバッグとログレベルを選択しましたか?そうでない場合は、Eclipseのデバッグの前提で

+0

は申し訳ありません私はあなたが何を意味するか得ることはありません...私はEclipseのデバッグパースペクティブで意味 – safari

+0

あなたはデバッグを選択する必要がありますあなたの情報のためにレベル –

+0

、私は他のすべてのログを参照してください... – safari

1

これはかなり古い投稿ですが、とにかくAndroid Studioで同じ問題が発生したときに私はここで終了しました。問題がある可能性があります以下、私と同じように、ここで終わるだろう人のために:

enter image description here

関連する問題