2016-03-22 14 views
0

Açıklama: I fragments.Like HomeFragment, firstFragment, secondFragment vb HomeFragment olarak , ben başka bir etkinliğe adaptörün bir niyet geçmiş olan bir adaptör olarak adlandırılan birden fazla var olan navigasyon çekmece.Neden etkinlik düğmesine geri basıldıktan sonra uygulama kapalı?

Geriye doğru bir uygulama düğmesine bastığımda, doğrudan arkadan kapatıldı. Burada

Başka Aktivite İşte

itemView.setOnClickListener(new View.OnClickListener() { 
      @Override 
      public void onClick(View v) { 
       String key=lst_key.get(position); 
       String status_value=list_status.get(position); 
       if(status_value.equals("notstarted")){ 
        Log.e("MATCH_KEY",""+key); 
        Intent intent=new Intent(context,NotStartedMatchDetails.class); 
        intent.putExtra("mainobj", lst.get(position).toString()); 
        context.startActivity(intent); 


//     MainActivity mainActivity=(MainActivity)context; 
//     Intent intent=new Intent(context,SummaryCard.class); 
//     intent.putExtra("Key",key); 
//     intent.putExtra("access_token",mainActivity.getMyData()); 
//     context.startActivity(intent); 
       } 
       if(status_value.equals("started")){ 
        Log.e("MATCH_KEY",""+key); 
        MainActivity mainActivity=(MainActivity)context; 
        Intent intent=new Intent(context,SummaryCard.class); 
        intent.putExtra("Key", key); 
        intent.putExtra("access_token",mainActivity.getMyData()); 
        context.startActivity(intent); 
       } 
      } 
     }); 

bir niyeti geçti benim adaptör benim etkinlik İşte

public class NotStartedMatchDetails extends AppCompatActivity { 

    Toolbar toolbar; 
    String str=""; 

    TextView txtA_team_name; 
    TextView txtB_team_name; 
    TextView txtDate; 
    TextView txtVanue; 
    TextView txtMatch_title; 
    Typeface tf; 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_not_started_match_details); 

     toolbar=(Toolbar)findViewById(R.id.toolbar); 
     setSupportActionBar(toolbar); 
     getSupportActionBar().setDisplayHomeAsUpEnabled(true); 
     tf=Typeface.createFromAsset(this.getResources().getAssets(), "Roboto-Regular.ttf"); 

     txtA_team_name=(TextView)findViewById(R.id.first_team_name); 
     txtB_team_name=(TextView)findViewById(R.id.second_team_name); 
     txtDate=(TextView)findViewById(R.id.date); 
     txtVanue=(TextView)findViewById(R.id.vanue); 

     txtA_team_name.setTypeface(tf,Typeface.BOLD); 
     txtB_team_name.setTypeface(tf,Typeface.BOLD); 
     txtDate.setTypeface(tf); 
     txtVanue.setTypeface(tf); 

     FrameLayout frameLayout=(FrameLayout)findViewById(R.id.adbar); 
     new AddLoader(this).LoadAds(frameLayout); 

     Bundle bundle=getIntent().getExtras(); 
     str=(String) bundle.get("mainobj"); 
     String key=(String)bundle.get("Key"); 

     Date date=null; 
     String ISTdateTime=""; 

     try{ 
      JSONObject mainObj=new JSONObject(str); 
      String name = mainObj.getString("name"); 
      String vanue=mainObj.getString("venue"); 
      String title=mainObj.getString("title"); 

      JSONObject start_date=mainObj.getJSONObject("start_date"); 
      String srt_date=start_date.getString("iso"); 

      try{ 
       DateFormat format=new SimpleDateFormat("yyyy-MM-dd'T'HH:mm'+00':ss"); 
       format.setTimeZone(TimeZone.getTimeZone("UTC")); 

       date=format.parse(srt_date); 

//    Sat Mar 19 19:30:00 GMT+05:30 2016 
       String[] name_parts; 
       String[] title_parts; 
       name_parts=name.split("vs"); 
       title_parts=title.split("-"); 

       ISTdateTime=date.toString(); 
       String[] ISTPARTS=ISTdateTime.split(" "); 
       String ISTdate=ISTPARTS[1]+" "+ISTPARTS[2]; 

       String ISTime=ISTPARTS[3]; 
       String[] Time_parts=ISTime.split(":"); 

       String hours=Time_parts[0]; 
       String minutes=Time_parts[1]; 

       String GMTDate=srt_date; 
       String[] GMT_parts=GMTDate.split("T"); 
       String gmt_time = GMT_parts[1]; 
       String[] gmt_hour_parts = gmt_time.split("\\+"); 
       String fullTime=ISTdate+","+hours+":"+minutes+" IST | "+gmt_hour_parts[0]+" GMT"; 

       txtA_team_name.setText(name_parts[0]); 
       txtB_team_name.setText(name_parts[1]); 
       txtDate.setText(fullTime); 
       txtVanue.setText(vanue); 
       getSupportActionBar().setTitle(title_parts[0]); 
      } 
      catch (Exception e){ 
       e.printStackTrace(); 
      } 
     } 
     catch (JSONException e){ 
      e.printStackTrace(); 
     } 
     try{ 
      SimpleDateFormat old_format =new SimpleDateFormat("HH:mm:ss"); 
      //oldDate.setTimeZone(TimeZone.getTimeZone("UTC")); 
      Date d1; 
      Date d2=null; 
//   Log.e("DAte",""+date.toString()); 
//   d1=oldDate.parse(oldDate.format(date)); 
//   Log.e("OLD DATE",""+d1.toString()); 

      d2=old_format.parse(old_format.format(new Date())); 
      Log.e("new date",""+d2.toString()); 

     } 
     catch (Exception e){ 
      e.printStackTrace(); 
     } 
    } 
    @Override 
    public boolean onOptionsItemSelected(MenuItem item) { 
     switch (item.getItemId()){ 
      case android.R.id.home: 
       Intent parentIntent = NavUtils.getParentActivityIntent(this); 
       parentIntent.setFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); 
       startActivity(parentIntent); 
       finish(); 
       return true; 
     } 
     return super.onOptionsItemSelected(item); 
    } 
} 

olduğunu

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

    <uses-permission android:name="android.permission.INTERNET" /> 
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 

    <application 
     android:allowBackup="true" 
     android:icon="@mipmap/ic_launcher" 
     android:label="@string/app_name" 
     android:theme="@style/MyMaterialTheme"> 
     <activity 
      android:name=".SplashScreen" 
      android:label="@string/app_name" 
      android:screenOrientation="portrait"> 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 

       <category android:name="android.intent.category.LAUNCHER" /> 
      </intent-filter> 
     </activity> 
     <activity 
      android:name=".MainActivity" 
      android:label="@string/app_name" 
      android:screenOrientation="portrait"></activity> 
     <activity 
      android:name=".NotStartedMatchDetails" 
      android:screenOrientation="portrait"> 
      <meta-data 
       android:name="android.support.PARENT_ACTIVITY" 
       android:value=".MainActivity"></meta-data> 
     </activity> 
     <activity 
      android:name=".SummaryCard" 
      android:parentActivityName=".MainActivity" 
      android:screenOrientation="portrait" 
      android:theme="@style/MyMaterialTheme"> 
      <meta-data 
       android:name="android.support.PARENT_ACTIVITY" 
       android:value=".MainActivity" /> 
     </activity> 
     <activity 
      android:name=".ScoreCard" 
      android:parentActivityName=".SummaryCard" 
      android:screenOrientation="portrait"> 
      <meta-data 
       android:name="android.support.PARENT_ACTIVITY" 
       android:value=".SummaryCard" /> 
     </activity> 
     <activity 
      android:name=".PlayerInfoDetails" 
      android:parentActivityName=".MainActivity" 
      android:screenOrientation="portrait"> 
      <meta-data 
       android:name="android.support.PARENT_ACTIVITY" 
       android:value=".MainActivity" /> 
     </activity> 
     <activity 
      android:name=".FullScore" 
      android:parentActivityName=".MainActivity" 
      android:screenOrientation="portrait"> 
      <meta-data 
       android:name="android.support.PARENT_ACTIVITY" 
       android:value=".MainActivity" /> 
     </activity> 

     <meta-data 
      android:name="com.google.android.gms.version" 
      android:value="@integer/google_play_services_version" /> 

     <activity android:name=".PlayerIccStats"></activity> 
    </application> 

</manifest> 

Sorun benim manifiest.xml dosyasıdır Etkinliğimin bir geri düğmesine bastığımda, bunun yerine bir uygulamayı doğrudan sonlandırmaya gider homeFragment'a gider.

Lütfen bu sorunu çözmek için bana yardımcı olun.

+0

hata günlüğü ekleyin .. –

+0

manifest dosyalarınızı gösterir –

+0

bir hata sağlar. –

cevap

1

Etkinliğinizi ön tarafa getirmek için niyeti taşıyan etiketleri kullanıyorsunuz, parentIntent.setFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); Bu, uygulamanızın neden kapanmasının nedeni olabilir, çünkü şimdi etkinliğiniz en ön sırada yer alıyor ve artık daha fazla etkinlik yığını yok ayrıldı.

İlgili konular