INTENT TRONG ANDROID NHẬN LẠI DATA SAU KHI PUTEXTRA NHƯ THẾ NÀO?

Pham Xuan Lu
Answered Mar 19th, 2018 2:12 a.m.
Trong activity1 protected void onActivityResult(int requestCode, int resultCode, Intent data)
dùng
String ten = data.getStringExtra("NAME);
thay vì Bundle bundle = getIntent().getExtras();
nhé
+2
Lỗi Build app.

Pham Xuan Lu
Answered Mar 14th, 2018 4:17 a.m.
Chạy với stacktrace debug xem chi tiết lỗi ở đâu nhé https://stackoverflow.com/questions/21674091/how-to-add-stacktrace-or-debug-option-when-building-android-studio-project
+1
Viết proguard cho Android như nào?

Pham Xuan Lu
Answered Jan 8th, 2018 9:40 a.m.
Kinh nghiệm thì a ko có nhưng có file proguard gia truyền.
Mặc định cho các project a đang dùng, ngoài ra có dùng thêm lib nào nữa thì thêm vào. thấy nó chạy mà ko có lỗi nào
Khi build xong nhớ lưu lại file maping để có crash còn map ngược lại code khi chưa obfucated
#================================= DEFAULT PROGUARD RULES =========================================#
#Use 5 step of optimization
-optimizationpasses 5
#When not preverifing in a case-insensitive filing system, such as Windows. This tool will unpack your processed jars,(if using windows you should then use):
-dontusemixedcaseclassnames
#Specifies not to ignore non-public library classes. As of version 4.5, this is the default setting
-dontskipnonpubliclibraryclasses
# Optimization is turned off by default. Dex does not like code run
# through the ProGuard optimize and preverify steps (and performs some
# of these optimizations on its own).
-dontoptimize
-dontpreverify
#Specifies to write out some more information during processing.
#If the program terminates with an exception, this option will print out the entire stack trace, instead of just the exception message.
-verbose
#Keep classes that are referenced on the AndroidManifest
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keep public class com.google.vending.licensing.ILicensingService
-keep public class com.android.vending.licensing.ILicensingService
#Compatibility library
-keep public class * extends android.support.v4.app.Fragment
-keep public class * extends android.app.Fragment
# keep setters in Views so that animations can still work.
# see http://proguard.sourceforge.net/manual/examples.html#beans
-keepclassmembers public class * extends android.view.View {
void set*(***);
*** get*();
}
#To remove debug logs:
-assumenosideeffects class android.util.Log {
public static *** d(...);
public static *** v(...);
public static *** w(...);
}
#Maintain java native methods
-keepclasseswithmembernames class * {
native <methods>;
}
#To maintain custom components names that are used on layouts XML:
-keep public class * extends android.view.View {
public <init>(android.content.Context);
}
-keep public class * extends android.view.View {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keep public class * extends android.view.View {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
#Maintain enums
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
#To keep parcelable classes (to serialize - deserialize objects to sent through Intents)
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
#Keep the R
-keepclassmembers class **.R$* {
public static <fields>;
}
-keep class com.google.android.gms.** { *; }
-dontwarn com.google.android.gms.**
-dontwarn android.support.v4.**
+11
Organizations
Have no organizations yet.