소스 검색

[공통][Bug] 카카오톡 앱링크 처리 보완
- 링크로 앱 시작을 한 경우 다시 앱 링크를 실행하면 SplashActivity.onCreate() 가 실행되지 않고 있다.
- 별도의 Activity 로 처리 등 필요

hyodong.min 7 년 전
부모
커밋
98d3ae9728

+ 10 - 6
app/src/main/AndroidManifest.xml

@@ -11,7 +11,7 @@
 
   <application
     android:name=".lifeplus.application.App"
-    android:allowBackup="true"
+    android:allowBackup="false"
     android:icon="@mipmap/ic_launcher"
     android:label="${appLabel}"
     android:roundIcon="@mipmap/ic_launcher_round"
@@ -28,10 +28,8 @@
       </intent-filter>
       <intent-filter>
         <action android:name="android.intent.action.VIEW"/>
-
         <category android:name="android.intent.category.DEFAULT"/>
         <category android:name="android.intent.category.BROWSABLE"/>
-
         <data
           android:host="@string/kakaolink_host"
           android:scheme="@string/kakao_scheme"/>
@@ -39,9 +37,9 @@
     </activity>
 
     <activity
-      android:name=".lifeplus.activity.LocationActivity"
-      android:screenOrientation="portrait"
-      android:windowSoftInputMode="adjustResize">
+      android:name=".lifeplus.activity.KakaoTalkActivity"
+      android:launchMode="singleTask"
+      android:screenOrientation="portrait">
     </activity>
 
     <activity
@@ -57,6 +55,12 @@
       android:windowSoftInputMode="adjustResize">
     </activity>
 
+    <activity
+      android:name=".lifeplus.activity.LocationActivity"
+      android:screenOrientation="portrait"
+      android:windowSoftInputMode="adjustResize">
+    </activity>
+
     <activity
       android:name="com.facebook.FacebookActivity"
       android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"

+ 6 - 2
app/src/main/java/kr/co/zumo/app/lifeplus/activity/ActivityBase.java

@@ -75,10 +75,16 @@ public abstract class ActivityBase extends AppCompatActivity {
 
   protected abstract void renderScreen();
 
+  protected abstract void onAfterDestroy();
+
+  protected abstract void onAfterNewIntent(Intent intent);
+
   @Override
   protected final void onNewIntent(Intent intent) {
     super.onNewIntent(intent);
     Log.w("APP# MainActivity | onNewIntent", "| >>>>>>>>>>>>>> " + this.getClass().getSimpleName() + " HC: " + this.hashCode());
+
+    onAfterNewIntent(intent);
   }
 
   @Override
@@ -128,8 +134,6 @@ public abstract class ActivityBase extends AppCompatActivity {
     super.onDestroy();
   }
 
-  protected abstract void onAfterDestroy();
-
   private boolean exitToBack() {
     // fragment 가 있다면.
     final FragmentBase fragment = (FragmentBase) getSupportFragmentManager().findFragmentById(R.id.container_main);

+ 36 - 0
app/src/main/java/kr/co/zumo/app/lifeplus/activity/KakaoTalkActivity.java

@@ -0,0 +1,36 @@
+package kr.co.zumo.app.lifeplus.activity;
+
+import android.net.Uri;
+import android.os.Bundle;
+import android.support.annotation.Nullable;
+import android.support.v7.app.AppCompatActivity;
+import android.util.Log;
+
+/**
+ * TestActivity
+ * <pre>
+ * </pre>
+ *
+ * @author 하세미
+ * @version 1.0
+ * @history 하세미   [2018-11-06]   [최초 작성]
+ * @since 2018-11-06
+ */
+public class KakaoTalkActivity extends AppCompatActivity{
+
+
+  @Override
+  protected void onCreate(@Nullable Bundle savedInstanceState) {
+    super.onCreate(savedInstanceState);
+
+    Log.e("APP#  KakaoTalkActivity | onCreate", "|");
+
+    Uri uri = getIntent().getData();
+    if (null != uri) {
+      Log.i("APP# KakaoTalkActivity | onCreate", "|" + uri.toString());
+    }
+
+    finish();
+  }
+
+}

+ 40 - 7
app/src/main/java/kr/co/zumo/app/lifeplus/activity/MainActivity.java

@@ -3,6 +3,9 @@
  */
 package kr.co.zumo.app.lifeplus.activity;
 
+import android.content.Intent;
+import android.util.Log;
+
 import com.google.gson.Gson;
 
 import kr.co.zumo.app.lifeplus.bean.ContentsDeliveryBean;
@@ -16,7 +19,6 @@ import kr.co.zumo.app.lifeplus.supervisor.ScreenID;
 import kr.co.zumo.app.lifeplus.util.StringUtil;
 import kr.co.zumo.app.lifeplus.view.screen.contents.ContentsFlagHelper;
 import kr.co.zumo.app.lifeplus.view.screen.factory.BasicFragmentFactory;
-import kr.co.zumo.app.lifeplus.view.screen.factory.FragmentFactory;
 
 /**
  * MainActivity
@@ -39,23 +41,54 @@ public class MainActivity extends ActivityBase {
     int screenId = new ScreenStarterIDMapper().getScreenId(fragmentFlag);
 
     // 첫 화면 표시
-    FragmentFactory factory = new BasicFragmentFactory();
-    ScreenChanger screenChanger = new FragmentSkipBackChanger(helper.getAppCompatActivity().getSupportFragmentManager(), helper.getContainerId(), factory, helper.getSkipBackIds());
+    ScreenChanger screenChanger = new FragmentSkipBackChanger(getSupportFragmentManager(), helper.getContainerId(), new BasicFragmentFactory(), helper.getSkipBackIds());
 
     // kakao 로 부터 진입했는지 확인
     String contentsString = getIntent().getStringExtra(ScreenStarter.SHARE_PARAMETER);
-    if(StringUtil.isFull(contentsString)) {
-      LifeplusContentsBean  lifeplusContentsBean = new Gson().fromJson(contentsString, LifeplusContentsBean.class);
+    Log.w("APP# MainActivity | renderScreen", "|>>>> " + contentsString);
+
+    int contentsScreenId = getContentsScreenId(contentsString);
+    if (contentsScreenId > -1) {
+      screenId = contentsScreenId;
+    }
+
+    screenChanger.changeTo(screenId);
+  }
+
+  @Override
+  protected void onAfterNewIntent(Intent intent) {
+    ScreenChangerHelper helper = getHelper(ScreenChangerHelper.class);
+
+    // kakao 로 부터 진입했는지 확인
+    String contentsString = intent.getStringExtra(ScreenStarter.SHARE_PARAMETER);
+
+    Log.w("APP# MainActivity | onAfterNewIntent", "|>> " + contentsString);
+
+    int screenId = getContentsScreenId(contentsString);
+
+    if (screenId > -1) {
+      // 첫 화면 표시
+      ScreenChanger screenChanger = new FragmentSkipBackChanger(getSupportFragmentManager(), helper.getContainerId(), new BasicFragmentFactory(), helper.getSkipBackIds());
+      screenChanger.changeTo(screenId);
+    }
+  }
+
+  protected int getContentsScreenId(String contentsString) {
+    int screenId = -1;
+
+    if (StringUtil.isFull(contentsString)) {
+      LifeplusContentsBean lifeplusContentsBean = new Gson().fromJson(contentsString, LifeplusContentsBean.class);
       ContentsDeliveryBean contentsDeliveryBean = new ContentsDeliveryBean.Builder(lifeplusContentsBean).build();
 
-      if(null != lifeplusContentsBean) {
+      if (null != lifeplusContentsBean) {
         DeliveryHelper deliveryHelper = getHelper(DeliveryHelper.class);
         deliveryHelper.setPackaging(contentsDeliveryBean);
 
         screenId = ScreenID.CONTENTS;
       }
     }
-    screenChanger.changeTo(screenId);
+
+    return screenId;
   }
 
   @Override

+ 7 - 0
app/src/main/java/kr/co/zumo/app/lifeplus/activity/NetworkErrorActivity.java

@@ -3,6 +3,8 @@
  */
 package kr.co.zumo.app.lifeplus.activity;
 
+import android.content.Intent;
+
 import kr.co.zumo.app.lifeplus.helper.ScreenChangerHelper;
 import kr.co.zumo.app.lifeplus.supervisor.FragmentSkipBackChanger;
 import kr.co.zumo.app.lifeplus.supervisor.ScreenChanger;
@@ -35,6 +37,11 @@ public class NetworkErrorActivity extends ActivityBase {
     screenChanger.changeTo(screenId);
   }
 
+  @Override
+  protected void onAfterNewIntent(Intent intent) {
+
+  }
+
   @Override
   protected void onAfterDestroy() {
 

+ 40 - 1
app/src/main/java/kr/co/zumo/app/lifeplus/activity/SplashActivity.java

@@ -45,6 +45,7 @@ public class SplashActivity extends AppCompatActivity {
     if (null != uri) {
       Log.i("APP# SplashActivity | onCreate", "|" + uri.toString());
     }
+
     final String param = null != uri ? uri.getQueryParameter(ShareKakaoTalk.CONTENTS_KEY) : "";
     getIntent().setData(null);
 
@@ -77,7 +78,7 @@ public class SplashActivity extends AppCompatActivity {
     Intent intent = new Intent(this, MainActivity.class);
     intent.putExtra(ScreenStarter.FLAG_FRAGMENT, fragmentFlag);
     intent.putExtra(ScreenStarter.SHARE_PARAMETER, param);
-    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
 
     startActivity(intent);
   }
@@ -86,6 +87,7 @@ public class SplashActivity extends AppCompatActivity {
     Intent intent = new Intent(this, MainActivity.class);
     intent.putExtra(ScreenStarter.FLAG_FRAGMENT, fragmentFlag);
     intent.putExtra(ScreenStarter.SHARE_PARAMETER, param);
+    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
 
     startActivity(intent);
   }
@@ -97,6 +99,42 @@ public class SplashActivity extends AppCompatActivity {
     finish();
   }
 
+  @Override
+  protected final void onRestoreInstanceState(Bundle savedInstanceState) {
+    super.onRestoreInstanceState(savedInstanceState);
+    Log.i("APP# SplashActivity | onRestoreInstanceState", "| >>>>>>>>>>>>>> " + this.getClass().getSimpleName() + " HC: " + this.hashCode());
+  }
+
+  @Override
+  protected final void onRestart() {
+    Log.i("APP# SplashActivity | onRestart", "| >>>>>>>>>>>>>> " + this.getClass().getSimpleName() + " HC: " + this.hashCode());
+    super.onRestart();
+  }
+
+  @Override
+  protected final void onStart() {
+    Log.i("APP# SplashActivity | onStart", "| >>>>>>>>>>>>>> " + this.getClass().getSimpleName() + " HC: " + this.hashCode());
+    super.onStart();
+  }
+
+  @Override
+  protected final void onResume() {
+    Log.i("APP# SplashActivity | onResume", "| >>>>>>>>>>>>>> " + this.getClass().getSimpleName() + " HC: " + this.hashCode());
+    super.onResume();
+  }
+
+  @Override
+  protected final void onPause() {
+    Log.i("APP# SplashActivity | onPause", "| <<<<<<<<<<<<< " + this.getClass().getSimpleName() + " HC: " + this.hashCode());
+    super.onPause();
+  }
+
+  @Override
+  protected final void onStop() {
+    Log.i("APP# SplashActivity | onStop", "| <<<<<<<<<<<<< " + this.getClass().getSimpleName() + " HC: " + this.hashCode());
+    super.onStop();
+  }
+
   protected void requestPermissions() {
     PermissionUtil.requestPermissions(this, new String[]{Manifest.permission.READ_PHONE_STATE}, 99);
   }
@@ -121,6 +159,7 @@ public class SplashActivity extends AppCompatActivity {
 
   @Override
   protected void onDestroy() {
+    Log.i("APP# SplashActivity | onDestroy", "| <<<<<<<<<<<<< " + this.getClass().getSimpleName() + " HC: " + this.hashCode());
     super.onDestroy();
 
     if (null != starter) {

+ 5 - 2
app/src/main/java/kr/co/zumo/app/lifeplus/model/SuperModel.java

@@ -23,9 +23,12 @@ public final class SuperModel {
   public static final int MEMBER_STATUS_BIT_REST = 1;   // 휴면
   public static final int MEMBER_STATUS_BIT_OUT = 2;    // 탈퇴
 
-  private static final SuperModel ourInstance = new SuperModel();
+  private static SuperModel ourInstance;
 
   public static SuperModel getInstance() {
+    if(null == ourInstance) {
+      ourInstance = new SuperModel();
+    }
     return ourInstance;
   }
 
@@ -65,7 +68,7 @@ public final class SuperModel {
    * dispose
    */
   public void dispose() {
-    initialized = false;
+    ourInstance = null;
     Log.e("APP#  SuperModel | dispose", "|" + " ------------------- dispose --------------------");
   }