我正在使用com.loopj.android:android-async-http:1.4.9我的服务器请求。在我的服务器中要求我使用SSL / TLS之前,它一直运行良好。因此,我需要修改AsyncHTTPClient以在所有URL中使用HTTPS。
我检查了类似的方法,如何使用AsyncHttpClient进行HTTPS调用?但没有提供明确的解决方案。由于库本身发出以下警告,因此可接受的解决方案也不安全:
警告!这会忽略每台设备上的SSL证书验证,请谨慎使用。
所以我继续检查其他解决方案。我最终遵循了以下建议:https : //developer.android.com/training/articles/security-ssl.html。因此,我有类似的东西:
// Load CAs from an InputStream
// (could be from a resource or ByteArrayInputStream or ...)
CertificateFactory cf = CertificateFactory.getInstance("X.509");
// From https://www.washington.edu/itconnect/security/ca/load-der.crt
InputStream caInput = new BufferedInputStream(new FileInputStream("load-der.crt"));
Certificate ca;
try {
ca = cf.generateCertificate(caInput);
System.out.println("ca=" + ((X509Certificate) ca).getSubjectDN());
} finally {
caInput.close();
}
// Create a KeyStore containing our trusted CAs
String keyStoreType = KeyStore.getDefaultType();
KeyStore keyStore = KeyStore.getInstance(keyStoreType);
keyStore.load(null, null);
keyStore.setCertificateEntry("ca", …Run Code Online (Sandbox Code Playgroud) 我正在使用下面的简单代码来获得在 DND 期间更改铃声的许可。应用正在 Android 6.0 上测试。但它因以下日志而崩溃
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.settings.NOTIFICATION_POLICY_ACCESS_SETTINGS }
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (!notificationManager.isNotificationPolicyAccessGranted()) {
startActivity(new Intent(ACTION_NOTIFICATION_POLICY_ACCESS_SETTINGS));
}
}
Run Code Online (Sandbox Code Playgroud)
我正在调用按钮单击。
我有这个自定义样式:
<resources>
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="AppTheme.AppText">
<item name="android:fontFamily">@font/book_family</item>
</style>
</resource>
Run Code Online (Sandbox Code Playgroud)
我通过在清单中添加以下内容,将此新样式作为主题应用于我的一个活动:
...
<activity android:name=".MyActivity"
android:theme="@style/AppTheme.AppText"/>
...
Run Code Online (Sandbox Code Playgroud)
结果不是我的预期.只有少数几个视图选择了自定义样式.下图显示了两个视图.第一个FIELD ONE没关系.FIELD TWO字段不会提取样式.
以下是这两个字段的定义:
<android.support.design.widget.TextInputLayout
android:id="@+id/til_email"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<AutoCompleteTextView
android:id="@+id/email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/prompt_email"
android:inputType="number"
android:imeOptions="actionNext"
android:maxLines="1"
android:singleLine="true" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/til_password"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<EditText
android:id="@+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/prompt_password"
android:imeActionId="6"
android:imeActionLabel="@string/action_sign_in_short"
android:imeOptions="actionUnspecified"
android:inputType="numberPassword"
android:maxLines="1"
android:singleLine="true" />
</android.support.design.widget.TextInputLayout>
Run Code Online (Sandbox Code Playgroud)
请问,任何想法?
库模块不能包含原始资源
我创建了一个示例 android 库模块,其中包含资产(不在应用程序模块中),然后生成 aar 文件。我分析了生成的 aar 文件,瞧,assets/ 文件夹仍然存在,所有文件都完好无损。
那么,到底是允许还是不允许呢?
根据这篇文章,我知道我可以通过如下声明您的活动来创建一个没有用户界面的活动:
<activity
android:name=".NoUIActivity"
android:theme="@android:style/Theme.NoDisplay">
</activity>
Run Code Online (Sandbox Code Playgroud)
我的问题是 NoUIActivity 扩展了 AppCompatActivity。如果我使用android:theme上面的行,它会给我错误提示我应该使用相应的 AppCompat 主题。请帮忙。谢谢!
我正在尝试从另一个目录包含我的 .so 库。编译我的项目工作正常。但是当我运行它时,它给了我
java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip 文件“/data/app/com.company.gimikapp-2/base.apk”],nativeLibraryDirectories=[/data/app/com.company.gimikapp -2/lib/arm、/vendor/lib、/system/lib]]] 找不到“libtheprebuiltlib.so”
我在 SO 中看到的常见解决方案是这样的:
sourceSets {
main {
jniLibs.srcDirs = ['src/main/jniLibs']
}
}
Run Code Online (Sandbox Code Playgroud)
两者都尝试过
jniLibs.srcDirs = ['C:\\svn\\sys_libs']
Run Code Online (Sandbox Code Playgroud)
和
jniLibs.srcDirs = ['C:/svn/sys_libs']
Run Code Online (Sandbox Code Playgroud)
实际上如何将其指向 Android 项目之外的另一个目录?
这是我的 CMakeList.txt:
cmake_minimum_required(VERSION 3.4.1)
add_library( native-lib
SHARED
src/main/cpp/source/native-lib.cpp )
add_library(theprebuiltlib SHARED IMPORTED)
set_target_properties(theprebuiltlib PROPERTIES IMPORTED_LOCATION
C:/svn/sys_libs/libtheprebuiltlib.so)
target_include_directories(
native-lib PRIVATE
src/main/cpp/source/
C:/svn/sys_includes/)
find_library( log-lib
log)
target_link_libraries( native-lib
theprebuiltlib
${log-lib})
Run Code Online (Sandbox Code Playgroud)
这是我的 JNI 的 gradle 设置:
android {
...
defaultConfig {
...
externalNativeBuild {
cmake {
cppFlags "-frtti -fexceptions"
}
ndk { …Run Code Online (Sandbox Code Playgroud) 我从我的 android 工作室收到此通知:
Google 搜索无法将应用编入索引;考虑添加至少一个带有 ACTION-VIEW 意图填充程序的 Activity。有关更多详细信息,请参阅问题说明。
添加深层链接,让您的应用进入 Google 索引,从 Google 搜索获取应用的安装量和流量。
环顾 Stackoverflow,我看到了这个。是的,我明白了,但它在 Google 搜索中会是什么样子?
我的gradle文件中有这个:
android {
signingConfigs {
mySigningConfig {
keyAlias 'theAlias'
keyPassword 'thePassword'
storeFile file('theKeystore.jks')
storePassword 'thePassword'
}
}
...
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.mySigningConfig
}
}
...
}
Run Code Online (Sandbox Code Playgroud)
然后当我生成我的发布 APK 时,我只需转到Build -> Build Bundle(s) / APK(s) -> Build APK(s)并创建 APK。与如果我去不同Build -> Generate Signed Bundle / APK,它会提示我:
我的问题是,我当前的 gradle 文件生成什么版本的签名?是V1还是V2?如何修改我的 gradle 文件,以便它专门使用 V1 或 V2 构建?
在应用程序中,我尝试以动画方式删除片段。
transaction.remove(fragmentVideo).remove(fragmentProgressBar).replace(R.id.content_pane_calling, endFragment);
transaction.setCustomAnimations(R.anim.slide_in, R.anim.slide_up);
transaction.commit();
Run Code Online (Sandbox Code Playgroud)
框架完全忽略了这一点。Fragment 本身被删除,但视觉效果并不好。任何动画都FragmentTransaction#replace可以很好地配合这些动画。我正在使用SupportLibrary v23.1.
谢谢你的协助 :)
cpp我在将文件夹和CMakelist.txt文件添加到 android studio 中的特定风格时遇到问题。
我正在开发三个具有独特数据库结构的独立应用程序,因此我尝试使用构建风格和其他相关设置将这三个应用程序作为一个应用程序。
对于前两个应用程序,它做得很好,但对于最后一个应用程序,我遇到了一个问题,我不知道如何使用 Gradle 将cpp文件夹和CMakelist.txt文件添加到特定风格。正如您可能已经猜到的,最后一个应用程序是基于 NDK 的,并且使用CMakelist.txt文件并具有与 JNI 配合使用的活动。
android {
...
defaultConfig {
applicationId "com.example"
...
externalNativeBuild {
cmake {
cppFlags ""
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
flavorDimensions 'program'
productFlavors {
first {
dimension = 'program'
applicationIdSuffix = '.first'
}
second {
dimension = 'program'
applicationIdSuffix = '.second'
}
third {
dimension = 'program'
applicationIdSuffix = '.third'
externalNativeBuild …Run Code Online (Sandbox Code Playgroud)