2012-02-07 2 views
2

내 응용 프로그램이 어떤 이유로 열리지 못했지만 두 번째로 열립니다. 이런 일이 발생하는 일반적인 이유가 있습니까? 여기 내 앱이 열리는 데 두 번 걸리는 이유는 무엇입니까?

이 주요 활동에 대한 코드, 정보는 크게 감상 할 수있다 :

package com.chich; 

import android.app.Activity; 

import android.app.PendingIntent; 
import android.content.ComponentName; 
import android.content.Intent; 
import android.content.pm.PackageManager; 
import android.os.Bundle; 
import android.telephony.gsm.SmsManager; 
import android.view.View; 
import android.view.View.OnClickListener; 
import android.widget.Button; 
import android.widget.EditText; 
import android.widget.Toast; 

public class chich_activity extends Activity 
{ 

Button btnSendSMS; 

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

    ComponentName locationReceiver = new ComponentName(this, SmsReceiver.class); 
    PackageManager pm = getPackageManager(); 
    pm.setComponentEnabledSetting(locationReceiver, 
      PackageManager.COMPONENT_ENABLED_STATE_DISABLED, 0); 



    btnSendSMS = (Button) findViewById(R.id.btnSendSMS); 
    btnSendSMS.setOnClickListener(new OnClickListener() 
    { 


     public void onClick(View v) 
     {  
      Intent i = new Intent(chich_activity.this, chich_activity2.class); 
      startActivity(i); 

    }  
}); 
    } 
} 

매니페스트 파일 :

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="com.chich" 
    android:versionCode="1" 
    android:versionName="1.0.0"> 
<application android:icon="@drawable/ic_launcher" android:label="@string/app_name"> 
    <activity android:name=".chich_activity" 
       android:label="@string/app_name"> 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 
      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
    </activity>  

     <activity android:name=".chich_activity2" 
       android:label="@string/app_name"> 
     <intent-filter> 
      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
    </activity> 

    <receiver android:name=".SmsReceiver"> 
     <intent-filter android:priority="9999999" > 
      <action android:name = "android.provider.Telephony.SMS_RECEIVED" /> 
     </intent-filter> 
    </receiver> 

</application> 
<uses-permission android:name="android.permission.SEND_SMS"> 
</uses-permission> 
<uses-permission android:name="android.permission.RECEIVE_SMS"> 
</uses-permission> 
</manifest> 
+2

충돌로 인한 오류를 게시하십시오. LogCat에서 찾을 수 있습니다. – WarrenFaith

+0

매니페스트 파일을 게시하십시오. –

+0

이상한데, 나는 어떤 오류도 내지 않고있다. 그것은 가까이에 강제로하지 않는다, 그냥 그게 뭔지로 마치면 – Christian

답변

1

답은 패키지 관리자에서 왔습니다. 같이 당신이 결국 쓰지 않는 경우가 응용 프로그램을 차단 밝혀, PackageManager.DONT_KILL_APP : 나는이 같은 문제가 있었다

ComponentName locationReceiver = new ComponentName(this, SmsReceiver.class); 
PackageManager pm = getPackageManager(); 
pm.setComponentEnabledSetting(locationReceiver, 
     PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); 
0

시도를 실행과 같은 하나의 활동을 떠나. 이 행을 제거하십시오 <category android:name="android.intent.category.LAUNCHER" /> 여기에서

<activity android:name=".chich_activity2" 
       android:label="@string/app_name"> 
     <intent-filter> 
      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
    </activity> 
+0

고마워,하지만 난 이미 그것을 시도하고 다시는 아무 소용이 없었어요. – Christian

0

, 나를 위해 가장 좋은 방법이지만 일을하지 않습니다!

switch(estado) { 
       case 0: 
        if (!tcursor.moveToFirst()){ 
         estado = 1; 

          Intent intentConfig=new Intent(getApplicationContext(),Configuracion.class); 
          startActivity(intentConfig); 
        } 
        break; 
       default: 

      } 
관련 문제