Skip to content

Commit

Permalink
Complete Sample
Browse files Browse the repository at this point in the history
  • Loading branch information
coleflowers committed Aug 10, 2018
1 parent 503e567 commit b65050b
Show file tree
Hide file tree
Showing 62 changed files with 5,615 additions and 1 deletion.
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
.externalNativeBuild
22 changes: 22 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions .idea/copyright/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 36 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/runConfigurations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
# roottools-android-studio
判断Android设备是否已越狱
判断Android设备是否已Root

-----
Code base on [softctrl/roottools][1]

[1]: https://github.com/softctrl/roottools
1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
24 changes: 24 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 18
buildToolsVersion "27.0.3"
defaultConfig {
applicationId "com.a52developer.androidinfo"
minSdkVersion 14
targetSdkVersion 27
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(path: ':library')
}
25 changes: 25 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in E:\Androidsdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
30 changes: 30 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.lovecode666.androidinfo">

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">

<activity
android:name="com.lovecode666.androidinfo.SplashActivity"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<activity
android:name="com.lovecode666.androidinfo.MainActivity"
android:theme="@android:style/Theme.NoTitleBar">
</activity>


</application>

</manifest>
85 changes: 85 additions & 0 deletions app/src/main/java/com/lovecode666/androidinfo/MainActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
package com.lovecode666.androidinfo;

/**
* Created by coleflowers on 2018/8/8.
* @copyright 爱写代码的小马
* @link https://coleflowers.github.io
*/

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;


import com.lovecode666.androidinfo.tools.Root;
import com.stericson.RootTools.RootTools;

import java.io.File;

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

TextView root_v1 = (TextView)findViewById(R.id.root_v1);
if(isRoot()){
root_v1.setText("已经ROOT");
} else {
root_v1.setText("还没有ROOT");
}

TextView root_v2 = (TextView)findViewById(R.id.root_v2);
if (new Root().isDeviceRooted()){
root_v2.setText("已经ROOT");
} else {
root_v2.setText("还没有ROOT");
}


// https://github.com/softctrl/roottools
TextView root_v3 = (TextView)findViewById(R.id.root_v3);
if (RootTools.isRootAvailable()){
root_v3.setText("已经ROOT");
} else {
root_v3.setText("还没有ROOT");
}

Button btn = (Button)findViewById(R.id.btn);
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String urlStr = "https://coleflowers.github.io";
Intent intent = new Intent(Intent.ACTION_VIEW).setData(Uri.parse(urlStr));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
});
}


/**
* 判断当前手机是否有ROOT权限
* @link http://www.cnblogs.com/rayray/p/3229265.html
* @return
*/
public boolean isRoot(){
boolean bool = false;

try{
if ((!new File("/system/bin/su").exists()) && (!new File("/system/xbin/su").exists())){
bool = false;
} else {
bool = true;
}
} catch (Exception e) {

}
return bool;
}
}
40 changes: 40 additions & 0 deletions app/src/main/java/com/lovecode666/androidinfo/SplashActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.lovecode666.androidinfo;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

import java.util.Timer;
import java.util.TimerTask;

/**
* Created by coleflowers on 2018/8/11.
*/

public class SplashActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);

TimerTask task = new TimerTask() {
@Override
public void run() {
startMain();
}
};
Timer timer = new Timer();
timer.schedule(task, 1200);

}

private void startMain(){
Intent intent = new Intent(SplashActivity.this, MainActivity.class);
startActivity(intent);
finish();
//overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
//finish();
}

}
Loading

0 comments on commit b65050b

Please sign in to comment.