我想检查我的包文件夹中是否存在文件,但我不想创建一个新文件.
File file = new File(filePath);
if(file.exists())
return true;
Run Code Online (Sandbox Code Playgroud)
是否在不创建新文件的情况下检查此代码?
我在Windows 10上使用Android studio 2.2.
我正在尝试导入现有的android项目.它永远需要的问题仍然显示消息
构建'ProjecTName'Graedle项目信息
之后,android工作室完全陷入困境,我从任务管理器中杀了它!
我尝试了Android Studio列表中的可用选项:
打开现有的Android Studio项目
导入项目(Eclipse ADT,Gradle等)
android android-studio build.gradle android-gradle-plugin android-studio-2.2
在我buildType
看来这个:
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
Run Code Online (Sandbox Code Playgroud)
我有一些问题:
我在尝试做一个新行时错误地做了TortoiseHG提交,并在提交消息中写了完全错误的东西.如何更改提交消息?
我还没有推动提交.
我将应用方向锁定为像这样的常规应用设置中的纵向
但是当我在ipad上运行我的应用程序时,它会旋转!?
那么我应该在哪里锁定方向?
为什么苹果将此功能添加到设置中,而它不起作用!?
更新:
我试图将这个viewController实现为所有viewController的通用.
import Foundation
import UIKit
class GeneralViewController: UIViewController {
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
let value = UIInterfaceOrientation.Portrait.rawValue
UIDevice.currentDevice().setValue(value, forKey: "orientation")
}
override func supportedInterfaceOrientations() -> Int {
return Int(UIInterfaceOrientationMask.Portrait.rawValue)
}
override func preferredInterfaceOrientationForPresentation() -> UIInterfaceOrientation {
return UIInterfaceOrientation.Portrait
}
override func shouldAutorotate() -> Bool {
return false
}
}
Run Code Online (Sandbox Code Playgroud)
这张照片取自我的应用程序的主导航控制器.
还是没用!
这个东西怎么样?
我有2个Android设备通过usb连接到我的电脑
现在,当我列出设备时,我得到了这个:
C:\Users\MBH>adb devices
List of devices attached
0123456789ABCDEF device
0123456789ABCDEF device
Run Code Online (Sandbox Code Playgroud)
两个设备都有相同的序列号,或者0123456789ABCDEF的含义.
问题:在这种情况下我无法做任何事情,既不推送或拉动文件,也不转发tcp端口.
C:\Users\MBH>adb forward tcp:59900 tcp:59900
error: more than one device/emulator
C:\Users\MBH>adb -s 0123456789ABCDEF forward tcp:59900 tcp:59900
error: more than one device
Run Code Online (Sandbox Code Playgroud)
问题:无论如何以不同的方式连接或选择设备?像设备型号或什么?
我用gradle更新到最新版本的Android studio 2.0 Beta 6:
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-beta6'
}
Run Code Online (Sandbox Code Playgroud)
该应用程序在模拟器和设备上运行完美,我测试了所有东西,它工作正常.
只有当我尝试生成签名APK时,我才会收到很多错误,
我在依赖项中遇到了一些错误,当我排除了矢量drawable,vector animate drawable和Support-v4库时,所有这些都解决了
现在我没有任何依赖性错误.
现在我的app模块的gradle.build看起来像这样:
apply plugin: 'com.android.application'
android {
configurations {
//all*.exclude group: 'com.android.support', module: 'support-v4'
all*.exclude module: 'animated-vector-drawable'
all*.exclude module: 'support-vector-drawable'
//all*.exclude module: 'support-v4'
}
repositories {
maven { url "https://jitpack.io" }
}
compileSdkVersion 23
buildToolsVersion '23.0.2'
defaultConfig {
applicationId "com.test.test"
minSdkVersion 11
targetSdkVersion 23
versionCode 1
versionName "1"
// multiDexEnabled true
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
} …
Run Code Online (Sandbox Code Playgroud) 一个执行器对象是否意味着在一个shutdown
?之后重用?我的意思是,如果我调用shutdown
或shutdownNow
在执行程序终止后,我应该new
创建一个新的线程池,还是可以以某种方式"重置"/重用以前终止的执行程序并重用它?
更新:
如果我需要创建新的线程池,我怎么能"理解"前一个已停止?
例如以下内容:
public void startPool(){
if(threadPool != null && !threadPool.isShutdown()){
return;
}
threadPool = Executors.newCachedThreadPool();
//other stuff
}
public void stopPool(){
if(threadPool != null){
threadPool.shutdown();
}
}
Run Code Online (Sandbox Code Playgroud)
不管用.如果我调用stop
然后start
由于条件将不会创建新的线程池.编码的正确方法是什么?
我使用此代码在多种语言app中手动设置默认语言:
public static void setLanguage(Context context, String languageCode){
Locale locale = new Locale(languageCode);
Locale.setDefault(locale);
Configuration config = new Configuration();
config.locale = locale; // Deprecated !!
context.getApplicationContext().getResources().updateConfiguration(config,
context.getResources().getDisplayMetrics());
}
Run Code Online (Sandbox Code Playgroud)
所以现在我们不能通过config.locale设置语言环境,因为该变量将在API 24中删除.
所以我看到另一种方法是设置:
config.setLocales();
现场
在API级别1中添加
区域设置
此字段在API级别24中已弃用.请勿直接设置或读取此字段.使用getLocales()和setLocales(LocaleList).如果只需要主要语言环境,则getLocales().get(0)现在是首选访问者.
区域设置的当前用户首选项,对应于区域设置资源限定符.
我也注意到,setLocale(Locale)
但是对于api 17及以上也是如此
我检查了setLocales(LocalList)文档,它以灰色标记,好像它也被弃用了!
那么什么可以解决这个问题!
android ×7
build.gradle ×2
adb ×1
concurrency ×1
file ×1
file-io ×1
gradle ×1
ios ×1
iphone ×1
java ×1
mercurial ×1
proguard ×1
swift ×1
tortoisehg ×1