13
13

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

本番用apkとテスト用apkで処理を切り替える方法

13
Posted at
Sample.java
	public boolean isDebuggable() {
        PackageManager manager = getPackageManager();
        ApplicationInfo appInfo = null;
        try {
            appInfo = manager.getApplicationInfo(getPackageName(), 0);
        } catch (NameNotFoundException e) {
            return false;
        }
 
        int debuggableFlag = appInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE;
        return (ApplicationInfo.FLAG_DEBUGGABLE == debuggableFlag);
    }

使う時

if (isDebuggable()){
  // テスト時の処理
}else{
  // 本場の処理
}
13
13
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
13
13

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?