├── AppCrashTracker
├── Sample~5e7f5f7a401c70a464939692c4608b40a2b8a669
├── images
│ └── 4654.png
├── ic_launcher-web.png
├── Sample
│ ├── ic_launcher-web.png
│ ├── libs
│ │ └── android-support-v4.jar
│ ├── res
│ │ ├── drawable-hdpi
│ │ │ └── ic_launcher.png
│ │ ├── drawable-mdpi
│ │ │ └── ic_launcher.png
│ │ ├── drawable-xhdpi
│ │ │ └── ic_launcher.png
│ │ ├── drawable-xxhdpi
│ │ │ └── ic_launcher.png
│ │ ├── values
│ │ │ ├── dimens.xml
│ │ │ ├── styles.xml
│ │ │ └── strings.xml
│ │ ├── values-v11
│ │ │ └── styles.xml
│ │ ├── values-w820dp
│ │ │ └── dimens.xml
│ │ ├── values-v14
│ │ │ └── styles.xml
│ │ └── layout
│ │ │ └── activity_main.xml
│ ├── .classpath
│ ├── src
│ │ └── com
│ │ │ └── example
│ │ │ └── act_sample
│ │ │ ├── Activity2.java
│ │ │ └── MainActivity.java
│ ├── project.properties
│ ├── proguard-project.txt
│ ├── .project
│ └── AndroidManifest.xml
├── src
│ └── com
│ │ └── org
│ │ └── appcrashtracker
│ │ ├── ACT.java
│ │ ├── PostValuesPair.java
│ │ └── ExceptionHandler.java
├── AndroidManifest.xml
├── .classpath
├── project.properties
├── proguard-project.txt
├── .project
├── res
│ └── values
│ │ └── strings.xml
└── build.xml
├── .gitattributes
├── .gitignore
└── README.md
/AppCrashTracker/Sample~5e7f5f7a401c70a464939692c4608b40a2b8a669:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/AppCrashTracker/images/4654.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macroday/AppCrashTracker/HEAD/AppCrashTracker/images/4654.png
--------------------------------------------------------------------------------
/AppCrashTracker/ic_launcher-web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macroday/AppCrashTracker/HEAD/AppCrashTracker/ic_launcher-web.png
--------------------------------------------------------------------------------
/AppCrashTracker/Sample/ic_launcher-web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macroday/AppCrashTracker/HEAD/AppCrashTracker/Sample/ic_launcher-web.png
--------------------------------------------------------------------------------
/AppCrashTracker/Sample/libs/android-support-v4.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macroday/AppCrashTracker/HEAD/AppCrashTracker/Sample/libs/android-support-v4.jar
--------------------------------------------------------------------------------
/AppCrashTracker/Sample/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macroday/AppCrashTracker/HEAD/AppCrashTracker/Sample/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/AppCrashTracker/Sample/res/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macroday/AppCrashTracker/HEAD/AppCrashTracker/Sample/res/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/AppCrashTracker/Sample/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macroday/AppCrashTracker/HEAD/AppCrashTracker/Sample/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/AppCrashTracker/Sample/res/drawable-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macroday/AppCrashTracker/HEAD/AppCrashTracker/Sample/res/drawable-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/AppCrashTracker/Sample/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 16dp
5 | 16dp
6 |
7 |
8 |
--------------------------------------------------------------------------------
/AppCrashTracker/src/com/org/appcrashtracker/ACT.java:
--------------------------------------------------------------------------------
1 | package com.org.appcrashtracker;
2 |
3 | import android.app.Activity;
4 | import android.content.Context;
5 |
6 | public class ACT {
7 |
8 | public static void init(Context context,Class> name)
9 | {
10 | Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler((Activity) context,name));
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/AppCrashTracker/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/AppCrashTracker/Sample/res/values-v11/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/AppCrashTracker/src/com/org/appcrashtracker/PostValuesPair.java:
--------------------------------------------------------------------------------
1 | package com.org.appcrashtracker;
2 |
3 | public class PostValuesPair {
4 |
5 | String key="",value="";
6 |
7 | public PostValuesPair(String key,String value) {
8 | this.key=key;
9 | this.value=value;
10 | }
11 |
12 | public String getKey()
13 | {
14 | return this.key;
15 | }
16 | public String getValue()
17 | {
18 | return this.value;
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | # Custom for Visual Studio
5 | *.cs diff=csharp
6 |
7 | # Standard to msysgit
8 | *.doc diff=astextplain
9 | *.DOC diff=astextplain
10 | *.docx diff=astextplain
11 | *.DOCX diff=astextplain
12 | *.dot diff=astextplain
13 | *.DOT diff=astextplain
14 | *.pdf diff=astextplain
15 | *.PDF diff=astextplain
16 | *.rtf diff=astextplain
17 | *.RTF diff=astextplain
18 |
--------------------------------------------------------------------------------
/AppCrashTracker/Sample/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 | 64dp
9 |
10 |
11 |
--------------------------------------------------------------------------------
/AppCrashTracker/Sample/res/values-v14/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/AppCrashTracker/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/AppCrashTracker/Sample/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/AppCrashTracker/Sample/src/com/example/act_sample/Activity2.java:
--------------------------------------------------------------------------------
1 | package com.example.act_sample;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.telephony.TelephonyManager;
6 | import android.util.Log;
7 |
8 | import com.org.appcrashtracker.ACT;
9 |
10 | public class Activity2 extends AppCompatActivity {
11 |
12 | @Override
13 | protected void onCreate(Bundle savedInstanceState) {
14 | super.onCreate(savedInstanceState);
15 | setContentView(R.layout.activity_main);
16 |
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/AppCrashTracker/Sample/src/com/example/act_sample/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.act_sample;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.util.Log;
6 |
7 | import com.org.appcrashtracker.ACT;
8 |
9 | public class MainActivity extends AppCompatActivity {
10 |
11 | @Override
12 | protected void onCreate(Bundle savedInstanceState) {
13 | super.onCreate(savedInstanceState);
14 | ACT.init(MainActivity.this,Activity2.class);
15 | setContentView(R.layout.activity_main);
16 |
17 | Log.i("", ""+Integer.parseInt("asdf"));
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/AppCrashTracker/Sample/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/AppCrashTracker/project.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must be checked in Version Control Systems.
5 | #
6 | # To customize properties used by the Ant build system edit
7 | # "ant.properties", and override values to adapt the script to your
8 | # project structure.
9 | #
10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
12 |
13 | # Project target.
14 | target=android-23
15 | android.library.reference.1=../android-support-v7-appcompat
16 | android.library=true
17 |
--------------------------------------------------------------------------------
/AppCrashTracker/Sample/project.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must be checked in Version Control Systems.
5 | #
6 | # To customize properties used by the Ant build system edit
7 | # "ant.properties", and override values to adapt the script to your
8 | # project structure.
9 | #
10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
12 |
13 | # Project target.
14 | target=android-23
15 | android.library.reference.1=..\\android-support-v7-appcompat
16 | android.library.reference.2=../AppCrashTracker
17 |
--------------------------------------------------------------------------------
/AppCrashTracker/Sample/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
14 |
15 |
16 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/AppCrashTracker/proguard-project.txt:
--------------------------------------------------------------------------------
1 | # To enable ProGuard in your project, edit project.properties
2 | # to define the proguard.config property as described in that file.
3 | #
4 | # Add project specific ProGuard rules here.
5 | # By default, the flags in this file are appended to flags specified
6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt
7 | # You can edit the include path and order by changing the ProGuard
8 | # include property in project.properties.
9 | #
10 | # For more details, see
11 | # http://developer.android.com/guide/developing/tools/proguard.html
12 |
13 | # Add any project specific keep options here:
14 |
15 | # If your project uses WebView with JS, uncomment the following
16 | # and specify the fully qualified class name to the JavaScript interface
17 | # class:
18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
19 | # public *;
20 | #}
21 |
--------------------------------------------------------------------------------
/AppCrashTracker/Sample/proguard-project.txt:
--------------------------------------------------------------------------------
1 | # To enable ProGuard in your project, edit project.properties
2 | # to define the proguard.config property as described in that file.
3 | #
4 | # Add project specific ProGuard rules here.
5 | # By default, the flags in this file are appended to flags specified
6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt
7 | # You can edit the include path and order by changing the ProGuard
8 | # include property in project.properties.
9 | #
10 | # For more details, see
11 | # http://developer.android.com/guide/developing/tools/proguard.html
12 |
13 | # Add any project specific keep options here:
14 |
15 | # If your project uses WebView with JS, uncomment the following
16 | # and specify the fully qualified class name to the JavaScript interface
17 | # class:
18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
19 | # public *;
20 | #}
21 |
--------------------------------------------------------------------------------
/AppCrashTracker/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | AppCrashTracker
4 |
5 |
6 |
7 |
8 |
9 | com.android.ide.eclipse.adt.ResourceManagerBuilder
10 |
11 |
12 |
13 |
14 | com.android.ide.eclipse.adt.PreCompilerBuilder
15 |
16 |
17 |
18 |
19 | org.eclipse.jdt.core.javabuilder
20 |
21 |
22 |
23 |
24 | com.android.ide.eclipse.adt.ApkBuilder
25 |
26 |
27 |
28 |
29 |
30 | com.android.ide.eclipse.adt.AndroidNature
31 | org.eclipse.jdt.core.javanature
32 |
33 |
34 |
--------------------------------------------------------------------------------
/AppCrashTracker/Sample/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | ACT_SAMPLE
4 |
5 |
6 |
7 |
8 |
9 | com.android.ide.eclipse.adt.ResourceManagerBuilder
10 |
11 |
12 |
13 |
14 | com.android.ide.eclipse.adt.PreCompilerBuilder
15 |
16 |
17 |
18 |
19 | org.eclipse.jdt.core.javabuilder
20 |
21 |
22 |
23 |
24 | com.android.ide.eclipse.adt.ApkBuilder
25 |
26 |
27 |
28 |
29 |
30 | com.android.ide.eclipse.adt.AndroidNature
31 | org.eclipse.jdt.core.javanature
32 |
33 |
34 |
--------------------------------------------------------------------------------
/AppCrashTracker/Sample/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
10 |
11 |
12 |
13 |
14 |
19 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Built application files
2 | *.apk
3 | *.ap_
4 |
5 | # Files for the Dalvik VM
6 | *.dex
7 |
8 | # Java class files
9 | *.class
10 |
11 | # Generated files
12 | bin/
13 | gen/
14 |
15 | # Gradle files
16 | .gradle/
17 | build/
18 | */build/
19 |
20 | # Local configuration file (sdk path, etc)
21 | local.properties
22 |
23 | # Proguard folder generated by Eclipse
24 | proguard/
25 |
26 | # Log Files
27 | *.log
28 |
29 | # Android Studio Navigation editor temp files
30 | .navigation/
31 |
32 | # Android Studio captures folder
33 | captures/
34 |
35 | # =========================
36 | # Operating System Files
37 | # =========================
38 |
39 | # OSX
40 | # =========================
41 |
42 | .DS_Store
43 | .AppleDouble
44 | .LSOverride
45 |
46 | # Thumbnails
47 | ._*
48 |
49 | # Files that might appear in the root of a volume
50 | .DocumentRevisions-V100
51 | .fseventsd
52 | .Spotlight-V100
53 | .TemporaryItems
54 | .Trashes
55 | .VolumeIcon.icns
56 |
57 | # Directories potentially created on remote AFP share
58 | .AppleDB
59 | .AppleDesktop
60 | Network Trash Folder
61 | Temporary Items
62 | .apdisk
63 |
64 | # Windows
65 | # =========================
66 |
67 | # Windows image file caches
68 | Thumbs.db
69 | ehthumbs.db
70 |
71 | # Folder config file
72 | Desktop.ini
73 |
74 | # Recycle Bin used on file shares
75 | $RECYCLE.BIN/
76 |
77 | # Windows Installer files
78 | *.cab
79 | *.msi
80 | *.msm
81 | *.msp
82 |
83 | # Windows shortcuts
84 | *.lnk
85 |
--------------------------------------------------------------------------------
/AppCrashTracker/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | AppCrashTracker
5 | default_url
6 | false
7 | false
8 | false
9 | false
10 | false
11 | false
12 | false
13 | false
14 | false
15 | false
16 | false
17 | false
18 | false
19 | false
20 | false
21 | false
22 | false
23 | false
24 | false
25 | false
26 | false
27 | false
28 | false
29 | false
30 | false
31 | false
32 | false
33 | false
34 | false
35 | false
36 | false
37 | false
38 | false
39 | false
40 | false
41 |
42 |
43 |
--------------------------------------------------------------------------------
/AppCrashTracker/Sample/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | ACT_SAMPLE
5 | Hello world!
6 | Settings
7 |
8 | your_url
9 | Activity2
10 | true
11 | true
12 | true
13 | true
14 | true
15 | true
16 | true
17 | true
18 | true
19 | true
20 | true
21 | true
22 | true
23 | true
24 | true
25 | true
26 | true
27 | true
28 | true
29 | true
30 | true
31 | true
32 | true
33 | true
34 | true
35 | true
36 | true
37 | true
38 | true
39 | true
40 | true
41 | true
42 | true
43 | true
44 | true
45 |
46 |
--------------------------------------------------------------------------------
/AppCrashTracker/build.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # AppCrashTracker
2 | Its a kind of toolkit to track the exception arising in the application and it will generate a json and can upload in your server using your own post url.
3 |
4 | No need to worry and think to add more line of code. Simple is better. So a single invoke is enough to make better app.
5 |
6 | Offline tracker coming soon!!
7 |
8 | [](https://android-arsenal.com/api?level=11)
9 | [](http://android-arsenal.com/details/1/2978)
10 |
11 |
12 | #Input
13 |
14 | ```java
15 |
16 | ACT.init(this,MainActivity.class);
17 |
18 | ```
19 |
20 | #Output
21 | ```jsonobject
22 | {
23 |
24 | "Package_Name" : com.example.act_sample,
25 |
26 | "VM_Max_Heap_Size" : 9.3 MB,
27 |
28 | "VM_free_Heap_Size" : 64 MB,
29 |
30 | "VM_Heap_Size" : 9.8 MB,
31 |
32 | "Internal_Memory_Size" : 503.4 MB,
33 |
34 | "Internal_Free_Space" : 100.3 MB,
35 |
36 | "Device_Orientation" : Portrait,
37 |
38 | "Screen_Layout" : Normal Screen,
39 |
40 | "SDCard_Status" : Mounted,
41 |
42 | "External_Free_Space" : 1.8 GB,
43 |
44 | "Battery_Percentage" : 100,
45 |
46 | "Device_IsRooted" : false,
47 |
48 | "Network_Mode" : Wifi,
49 |
50 | "Battery_Charging_Via" : USB,
51 |
52 | "Native_Allocated_Size" : 2 MB,
53 |
54 | "External_Memory_Size" : 7.4 GB,
55 |
56 | "Allocated_VM_Size" : 482.1 kB,
57 |
58 | "Brand" : Google Nexus,
59 |
60 | "Model" : Nexus 5,
61 |
62 | "Product" : Nexus 5,
63 |
64 | "Device" : 5x,
65 |
66 | "Message" : Unable to start activity ComponentInfo{com.example.act_sample\/com.example.act_sample.MainActivity}: java.lang.NumberFormatException: Invalid int: \"asdf\",
67 |
68 | "Incremental" : eng.terry.1365412624,
69 |
70 | "Height" : 854,
71 |
72 | "SDK" : 16,
73 |
74 | "Release" : 4.1.1,
75 |
76 | "Localized_Message" : Unable to start activity ComponentInfo{com.example.act_sample\/com.example.act_sample.MainActivity}: java.lang.NumberFormatException: Invalid int: \"asdf\",
77 |
78 | "Tablet" : false,
79 |
80 | "Class" : MainActivity,
81 |
82 | "App_Version" : 1.0,
83 |
84 | "Width" : 480,
85 |
86 | "Stack_Trace" : java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.act_sample\/com.example.act_sample.MainActivity}:
87 | java.lang.NumberFormatException: Invalid int: \"asdf\"
88 | android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2184)
89 | android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2211)
90 | android.app.ActivityThread.access$600(ActivityThread.java:149)
91 | android.app.ActivityThread$H.handleMessage(ActivityThread.java:1300)
92 | android.os.Handler.dispatchMessage(Handler.java:99)
93 | android.os.Looper.loop(Looper.java:153)
94 | android.app.ActivityThread.main(ActivityThread.java:5086)
95 | java.lang.reflect.Method.invokeNative(Native Method)
96 | java.lang.reflect.Method.invoke(Method.java:511)
97 | com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:821)
98 | com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
99 | dalvik.system.NativeStart.main(Native Method)
100 | Caused by: java.lang.NumberFormatException: Invalid int: \"asdf\"
101 | java.lang.Integer.invalidInt(Integer.java:138)
102 | java.lang.Integer.parse(Integer.java:375)
103 | java.lang.Integer.parseInt(Integer.java:366)
104 | java.lang.Integer.parseInt(Integer.java:332)
105 | com.example.act_sample.MainActivity.onCreate(MainActivity.java:17)
106 | android.app.Activity.performCreate(Activity.java:5020)
107 | android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
108 | android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
109 | ... 11 more,
110 |
111 | "Cause" : java.lang.NumberFormatException: Invalid int: \"asdf\"
112 |
113 | "Country" : India
114 | }
115 | ```
116 |
117 | #Requirements
118 |
119 |
120 | - Init from onCreate Method with context and default class
-
121 |
- Add Interent Permission
-
122 |
- Add Access Network State Permission
-
123 |
- Add Configuration in String.xml . Please refer Configuration link
124 |
125 |
126 | #Configuration
127 | Its nothing but, you can customize the data come out from the result. For example, if you want to see the sdk version of the device means, you just add a bool in to string.xml to true. Enough!
128 | The bool must the same name. Those are following
129 |
130 | ```xml
131 | post_url
132 | ture
133 | true
134 | true
135 | true
136 | true
137 | false
138 | false
139 | false
140 | false
141 | false
142 | false
143 | false
144 | false
145 | false
146 | false
147 | false
148 | false
149 | false
150 | false
151 | false
152 | false
153 | false
154 | false
155 | false
156 | false
157 | false
158 | false
159 | false
160 | false
161 | false
162 | false
163 | false
164 | false
165 | false
166 | false
167 |
168 | ```
169 |
170 |
171 |
172 | #API Level
173 | 2.2 to Latest
174 |
175 | #License
176 | ```license
177 | Copyright 2015-2016 Ganesh Krishnamoorthy
178 |
179 | Licensed under the Apache License, Version 2.0 (the "License");
180 | you may not use this file except in compliance with the License.
181 | You may obtain a copy of the License at
182 |
183 | http://www.apache.org/licenses/LICENSE-2.0
184 |
185 | Unless required by applicable law or agreed to in writing, software
186 | distributed under the License is distributed on an "AS IS" BASIS,
187 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
188 | See the License for the specific language governing permissions and
189 | limitations under the License.
190 |
191 | ```
192 |
193 | Please give me feedback! Thanks!!
194 |
195 |
196 | [](https://bitdeli.com/free "Bitdeli Badge")
197 |
198 |
--------------------------------------------------------------------------------
/AppCrashTracker/src/com/org/appcrashtracker/ExceptionHandler.java:
--------------------------------------------------------------------------------
1 | package com.org.appcrashtracker;
2 |
3 | import java.io.BufferedWriter;
4 | import java.io.File;
5 | import java.io.IOException;
6 | import java.io.OutputStream;
7 | import java.io.OutputStreamWriter;
8 | import java.io.PrintWriter;
9 | import java.io.StringWriter;
10 | import java.io.UnsupportedEncodingException;
11 | import java.net.HttpURLConnection;
12 | import java.net.MalformedURLException;
13 | import java.net.ProtocolException;
14 | import java.net.URL;
15 | import java.net.URLEncoder;
16 | import java.text.DecimalFormat;
17 | import java.util.ArrayList;
18 | import java.util.List;
19 | import java.util.Locale;
20 |
21 | import org.json.JSONException;
22 | import org.json.JSONObject;
23 |
24 | import android.Manifest;
25 | import android.app.Activity;
26 | import android.content.Context;
27 | import android.content.Intent;
28 | import android.content.IntentFilter;
29 | import android.content.pm.PackageInfo;
30 | import android.content.pm.PackageManager;
31 | import android.content.pm.PackageManager.NameNotFoundException;
32 | import android.content.res.Configuration;
33 | import android.net.ConnectivityManager;
34 | import android.net.NetworkInfo;
35 | import android.os.AsyncTask;
36 | import android.os.BatteryManager;
37 | import android.os.Build;
38 | import android.os.Debug;
39 | import android.os.Environment;
40 | import android.os.StatFs;
41 | import android.os.StrictMode;
42 | import android.telephony.TelephonyManager;
43 | import android.util.Log;
44 | import android.view.Display;
45 |
46 | public class ExceptionHandler implements
47 | java.lang.Thread.UncaughtExceptionHandler {
48 | private final Activity activity;
49 | Intent intent ;
50 | JSONObject jObjectData;
51 | String ActivityName;
52 | Class> name;
53 | String Post_Url;
54 |
55 | private boolean class_name = false;
56 | private boolean message = false;
57 | private boolean localized_message = false;
58 | private boolean causes = false;
59 | private boolean stack_trace = false;
60 | private boolean brand_name = false;
61 | private boolean device_name = false;
62 | private boolean model_number = false;
63 | private boolean product_name = false;
64 | private boolean sdk_version = false;
65 | private boolean release = false;
66 | private boolean incremental = false;
67 | private boolean height = false;
68 | private boolean width = false;
69 | private boolean app_version = false;
70 | private boolean tablet = false;
71 | private boolean device_orientation = false;
72 | private boolean screen_layout = false;
73 | private boolean vm_heap_size = false;
74 | private boolean allocated_vm_size = false;
75 | private boolean vm_max_heap_size = false;
76 | private boolean vm_free_heap_size = false;
77 | private boolean native_allocated_size = false;
78 | private boolean battery_percentage = false;
79 | private boolean battery_charging = false;
80 | private boolean battery_charging_via= false;
81 | private boolean sd_card_status= false;
82 | private boolean internal_memory_size= false;
83 | private boolean external_memory_size= false;
84 | private boolean internal_free_space= false;
85 | private boolean external_free_space= false;
86 | private boolean package_name= false;
87 | private boolean device_rooted= false;
88 | private boolean network_mode= false;
89 | private boolean country= false;
90 |
91 | public ExceptionHandler(Activity activity,Class> name) {
92 | this.activity = activity;
93 | this.name=name;
94 | ActivityName=activity.getClass().getSimpleName();
95 |
96 | this.Post_Url=activity.getResources().getString(R.string.url);
97 | if(Post_Url.equals("default_url"))
98 | Log.e(""+activity.getPackageName(), "Post url not specified");
99 | else
100 | {
101 | class_name = activity.getResources().getBoolean(R.bool.class_name);
102 | message = activity.getResources().getBoolean(R.bool.message);
103 | localized_message = activity.getResources().getBoolean(R.bool.localized_message);
104 | causes = activity.getResources().getBoolean(R.bool.causes);
105 | stack_trace = activity.getResources().getBoolean(R.bool.stack_trace);
106 | brand_name = activity.getResources().getBoolean(R.bool.brand_name);
107 | device_name = activity.getResources().getBoolean(R.bool.device_name);
108 | model_number = activity.getResources().getBoolean(R.bool.model_number);
109 | product_name = activity.getResources().getBoolean(R.bool.product_name);
110 | sdk_version = activity.getResources().getBoolean(R.bool.sdk_version);
111 | release = activity.getResources().getBoolean(R.bool.release);
112 | incremental = activity.getResources().getBoolean(R.bool.incremental);
113 | height = activity.getResources().getBoolean(R.bool.height);
114 | width = activity.getResources().getBoolean(R.bool.width);
115 | app_version = activity.getResources().getBoolean(R.bool.app_version);
116 | tablet = activity.getResources().getBoolean(R.bool.tablet);
117 | device_orientation=activity.getResources().getBoolean(R.bool.device_orientation);
118 | screen_layout=activity.getResources().getBoolean(R.bool.screen_layout);
119 | vm_heap_size = activity.getResources().getBoolean(R.bool.vm_heap_size);
120 | allocated_vm_size = activity.getResources().getBoolean(R.bool.allocated_vm_size);
121 | vm_max_heap_size = activity.getResources().getBoolean(R.bool.vm_max_heap_size);
122 | vm_free_heap_size = activity.getResources().getBoolean(R.bool.vm_free_heap_size);
123 | native_allocated_size = activity.getResources().getBoolean(R.bool.native_allocated_size);
124 | battery_percentage = activity.getResources().getBoolean(R.bool.battery_percentage);
125 | battery_charging = activity.getResources().getBoolean(R.bool.battery_charging);
126 | battery_charging_via = activity.getResources().getBoolean(R.bool.battery_charging_via);
127 | sd_card_status = activity.getResources().getBoolean(R.bool.sd_card_status);
128 | internal_memory_size = activity.getResources().getBoolean(R.bool.internal_memory_size);
129 | external_memory_size = activity.getResources().getBoolean(R.bool.external_memory_size);
130 | internal_free_space = activity.getResources().getBoolean(R.bool.internal_free_space);
131 | external_free_space = activity.getResources().getBoolean(R.bool.external_free_space);
132 | package_name = activity.getResources().getBoolean(R.bool.package_name);
133 | device_rooted = activity.getResources().getBoolean(R.bool.device_rooted);
134 | network_mode = activity.getResources().getBoolean(R.bool.network_mode);
135 | country = activity.getResources().getBoolean(R.bool.country);
136 | }
137 | }
138 |
139 | @SuppressWarnings("deprecation")
140 | public void uncaughtException(Thread thread, Throwable exception) {
141 | StringWriter stackTrace = new StringWriter();
142 | exception.printStackTrace(new PrintWriter(stackTrace));
143 |
144 | StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
145 | StrictMode.setThreadPolicy(policy);
146 |
147 | jObjectData = new JSONObject();
148 | try {
149 | if(package_name)
150 | jObjectData.put("Package_Name", activity.getPackageName());
151 | if(class_name)
152 | jObjectData.put("Class", ActivityName);
153 | if(message)
154 | jObjectData.put("Message", exception.getMessage());
155 | if(localized_message)
156 | jObjectData.put("Localized_Message", exception.getLocalizedMessage());
157 | if(causes)
158 | jObjectData.put("Cause", exception.getCause());
159 | if(stack_trace)
160 | jObjectData.put("Stack_Trace", stackTrace.toString());
161 | if(brand_name)
162 | jObjectData.put("Brand", Build.BRAND);
163 | if(device_name)
164 | jObjectData.put("Device", Build.DEVICE);
165 | if(model_number)
166 | jObjectData.put("Model", Build.MODEL);
167 | if(product_name)
168 | jObjectData.put("Product", Build.PRODUCT);
169 | if(sdk_version)
170 | jObjectData.put("SDK", Build.VERSION.SDK);
171 | if(release)
172 | jObjectData.put("Release",Build.VERSION.RELEASE);
173 | if(incremental)
174 | jObjectData.put("Incremental", Build.VERSION.INCREMENTAL);
175 | if(height)
176 | jObjectData.put("Height", activity.getResources().getDisplayMetrics().heightPixels);
177 | if(width)
178 | jObjectData.put("Width", activity.getResources().getDisplayMetrics().widthPixels);
179 | if(app_version)
180 | jObjectData.put("App_Version", getAppVersion(activity));
181 | if(tablet)
182 | jObjectData.put("Tablet", isTablet(activity));
183 | if(device_orientation)
184 | jObjectData.put("Device_Orientation", getScreenOrientation(activity));
185 | if(screen_layout)
186 | jObjectData.put("Screen_Layout", getScreenLayout(activity));
187 | if(vm_heap_size)
188 | jObjectData.put("VM_Heap_Size", ConvertSize(Runtime.getRuntime().totalMemory()));
189 | if(allocated_vm_size)
190 | jObjectData.put("Allocated_VM_Size", ConvertSize(Runtime.getRuntime().freeMemory()));
191 | if(vm_max_heap_size)
192 | jObjectData.put("VM_Max_Heap_Size", ConvertSize((Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory())));
193 | if(vm_free_heap_size)
194 | jObjectData.put("VM_free_Heap_Size", ConvertSize(Runtime.getRuntime().maxMemory()));
195 | if(native_allocated_size)
196 | jObjectData.put("Native_Allocated_Size", ConvertSize(Debug.getNativeHeapAllocatedSize()));
197 | if(battery_percentage)
198 | jObjectData.put("Battery_Percentage", activity.registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED)).getIntExtra(BatteryManager.EXTRA_LEVEL, 0));
199 | if(battery_charging)
200 | jObjectData.put("Battery_Charging_Status", getBatteryStatus(activity));
201 | if(battery_charging_via)
202 | jObjectData.put("Battery_Charging_Via", getBatteryChargingMode(activity));
203 | if(sd_card_status)
204 | jObjectData.put("SDCard_Status", getSDCardStatus(activity));
205 | if(internal_memory_size)
206 | jObjectData.put("Internal_Memory_Size", getTotalInternalMemorySize());
207 | if(external_memory_size)
208 | jObjectData.put("External_Memory_Size", getTotalExternalMemorySize());
209 | if(internal_free_space)
210 | jObjectData.put("Internal_Free_Space", getAvailableInternalMemorySize());
211 | if(external_free_space)
212 | jObjectData.put("External_Free_Space", getAvailableExternalMemorySize());
213 | if(device_rooted)
214 | jObjectData.put("Device_IsRooted", isRooted());
215 | if(network_mode)
216 | jObjectData.put("Network_Mode", getNetworkMode(activity));
217 | if(country)
218 | jObjectData.put("Country", new Locale("",activity.getResources().getConfiguration().locale.getCountry()).getDisplayCountry());
219 | } catch (JSONException e) {
220 | Log.e(""+activity.getPackageName(), "JSON Exception");
221 | }
222 | Log.i("", ">>>>>>>>>>>>>>>>>>"+((TelephonyManager) activity.getSystemService(Context.TELEPHONY_SERVICE)).getNetworkOperatorName());
223 |
224 |
225 | if(activity.getPackageManager().checkPermission(Manifest.permission.INTERNET, activity.getPackageName()) == PackageManager.PERMISSION_GRANTED)
226 | {
227 | if(activity.getPackageManager().checkPermission(Manifest.permission.ACCESS_NETWORK_STATE, activity.getPackageName()) == PackageManager.PERMISSION_GRANTED)
228 | {
229 | if(isConnectingToInternet(activity))
230 | {
231 |
232 | if (class_name || message || localized_message || causes
233 | || stack_trace || brand_name || device_name
234 | || model_number || product_name || sdk_version
235 | || release || incremental || height || width
236 | || app_version || tablet || device_orientation
237 | || screen_layout || vm_heap_size
238 | || allocated_vm_size || vm_max_heap_size
239 | || vm_free_heap_size || native_allocated_size
240 | || battery_percentage || battery_charging
241 | || battery_charging_via || sd_card_status
242 | || internal_memory_size || external_memory_size
243 | || internal_free_space || external_free_space
244 | || package_name || device_rooted || network_mode || country) {
245 | new AsyncTask() {
246 |
247 | @Override
248 | protected Void doInBackground(Void... arg0) {
249 | try{
250 | URL url = null;
251 | try {
252 | url = new URL(Post_Url);
253 | } catch (MalformedURLException e1) {
254 | Log.e(""+activity.getPackageName(), "MalformedURLExcpetion");
255 | }
256 | HttpURLConnection conn = null;
257 | try {
258 | conn = (HttpURLConnection) url.openConnection();
259 | } catch (IOException e1) {
260 | Log.e(""+activity.getPackageName(), "IOException");
261 | }
262 | try {
263 | conn.setRequestMethod("POST");
264 | } catch (ProtocolException e1) {
265 | Log.e(""+activity.getPackageName(), "ProtocolException");
266 | }
267 | conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
268 | conn.setDoInput(true);
269 | conn.setDoOutput(true);
270 | List params1 = new ArrayList();
271 | params1.add(new PostValuesPair("error_report", jObjectData.toString()));
272 | try{
273 | OutputStream os = conn.getOutputStream();
274 | BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(os, "UTF-8"));
275 | writer.write(getQuery(params1));
276 | writer.flush();
277 | writer.close();
278 | os.close();
279 | }
280 | catch(Exception ee)
281 | {
282 | Log.e(""+activity.getPackageName(), "Buffer Write Exception");
283 | }
284 | try {
285 | conn.connect();
286 | } catch (IOException e1) {
287 | Log.e(""+activity.getPackageName(), "IOException");
288 | }
289 | } catch (Exception e) {
290 | Log.e(""+activity.getPackageName(), "Exception Occurred");
291 | }
292 |
293 | return null;
294 | }
295 | }.execute();
296 | }
297 | else
298 | Log.e(""+activity.getPackageName(), "Not configured. Set configuration in string.xml");
299 | }
300 | else
301 | Log.e(""+activity.getPackageName(), "Network not found");
302 | }
303 | else
304 | Log.e(""+activity.getPackageName(), "Need to add Access newtork state permission");
305 | }
306 | else
307 | Log.e(""+activity.getPackageName(), "Need to add internet permission");
308 |
309 | intent = new Intent(activity, name);
310 | activity.startActivity(intent);
311 |
312 | android.os.Process.killProcess(android.os.Process.myPid());
313 | System.exit(10);
314 |
315 | }
316 | public String getAppVersion(Context con)
317 | {
318 | PackageManager manager = con.getPackageManager();
319 | PackageInfo info = null;
320 | try {
321 | info = manager.getPackageInfo(con.getPackageName(), 0);
322 | } catch (NameNotFoundException e) {
323 | Log.e(""+activity.getPackageName(), "Name not found Exception");
324 | }
325 | return info.versionName;
326 | }
327 |
328 | public boolean isTablet(Context con) {
329 | boolean xlarge = ((con.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == 4);
330 | boolean large = ((con.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE);
331 | return xlarge || large;
332 | }
333 |
334 | public String getQuery(List params) throws UnsupportedEncodingException
335 | {
336 | StringBuilder result = new StringBuilder();
337 | boolean first = true;
338 |
339 | for (PostValuesPair pair : params)
340 | {
341 | if (first)
342 | first = false;
343 | else
344 | result.append("&");
345 |
346 | result.append(URLEncoder.encode(pair.getKey(), "UTF-8"));
347 | result.append("=");
348 | result.append(URLEncoder.encode(pair.getValue(), "UTF-8"));
349 | }
350 |
351 | return result.toString();
352 | }
353 |
354 | @SuppressWarnings("deprecation")
355 | public boolean isConnectingToInternet(Activity act){
356 | boolean isthere = false;
357 | TelephonyManager tm = (TelephonyManager) act.getSystemService(Context.TELEPHONY_SERVICE);
358 | if (tm.getSimState() != TelephonyManager.SIM_STATE_UNKNOWN){
359 | ConnectivityManager connectivityManager = (ConnectivityManager) act.getSystemService(Context.CONNECTIVITY_SERVICE);
360 | if ((connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).getState() == NetworkInfo.State.CONNECTED ||connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI).getState() == NetworkInfo.State.CONNECTED))
361 | isthere = true;
362 | } else {
363 | ConnectivityManager connectivityManager = (ConnectivityManager) act.getSystemService(Context.CONNECTIVITY_SERVICE);
364 | if ((connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI).getState() == NetworkInfo.State.CONNECTED))
365 | isthere = true;
366 | }
367 | return isthere;
368 | }
369 |
370 | @SuppressWarnings("deprecation")
371 | public String getScreenOrientation(Activity act)
372 | {
373 | Display getOrient = act.getWindowManager().getDefaultDisplay();
374 | if(getOrient.getWidth()==getOrient.getHeight()){
375 | return "Square";
376 | }
377 | else
378 | {
379 | if(getOrient.getWidth() < getOrient.getHeight()){
380 | return "Portrait";
381 | }
382 | else
383 | {
384 | return "Landscape";
385 | }
386 | }
387 | }
388 | public String getScreenLayout(Activity act)
389 | {
390 | int screenSize = act.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK;
391 | switch (screenSize) {
392 | case Configuration.SCREENLAYOUT_SIZE_LARGE:
393 | return "Large Screen";
394 | case Configuration.SCREENLAYOUT_SIZE_NORMAL:
395 | return "Normal Screen";
396 | case Configuration.SCREENLAYOUT_SIZE_SMALL:
397 | return "Small Screen";
398 | default:
399 | return "Screen size is neither large, normal or small";
400 | }
401 | }
402 |
403 | public String ConvertSize(long size) {
404 | if(size <= 0) return "0";
405 | final String[] units = new String[] { "B", "kB", "MB", "GB", "TB" };
406 | int digitGroups = (int) (Math.log10(size)/Math.log10(1024));
407 | return new DecimalFormat("#,##0.#").format(size/Math.pow(1024, digitGroups)) + " " + units[digitGroups];
408 | }
409 |
410 | public String getBatteryStatus(Activity act)
411 | {
412 | int status=act.registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED)).getIntExtra(BatteryManager.EXTRA_STATUS,-1);
413 | if(status==BatteryManager.BATTERY_STATUS_CHARGING)
414 | return "Charging";
415 | else if (status==BatteryManager.BATTERY_STATUS_DISCHARGING)
416 | return "Discharging";
417 | else if(status==BatteryManager.BATTERY_STATUS_FULL)
418 | return "Full";
419 | return "NULL";
420 | }
421 |
422 | public String getBatteryChargingMode(Activity act)
423 | {
424 | int plugged = act.registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED)).getIntExtra(BatteryManager.EXTRA_PLUGGED, -1);
425 | if(plugged == BatteryManager.BATTERY_PLUGGED_AC)
426 | return "AC";
427 | else if(plugged == BatteryManager.BATTERY_PLUGGED_USB)
428 | return "USB";
429 | else if(plugged == BatteryManager.BATTERY_PLUGGED_WIRELESS)
430 | return "WireLess";
431 | return "NULL";
432 | }
433 |
434 | public String getSDCardStatus(Activity act)
435 | {
436 | Boolean isSDPresent = android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED);
437 | if(isSDPresent)
438 | return "Mounted";
439 | else
440 | return "Not mounted";
441 | }
442 |
443 | @SuppressWarnings("deprecation")
444 | public String getAvailableInternalMemorySize() {
445 | File path = Environment.getDataDirectory();
446 | StatFs stat = new StatFs(path.getPath());
447 | long blockSize = stat.getBlockSize();
448 | long availableBlocks = stat.getAvailableBlocks();
449 | return ConvertSize(availableBlocks * blockSize);
450 | }
451 |
452 | @SuppressWarnings("deprecation")
453 | public String getTotalInternalMemorySize() {
454 | File path = Environment.getDataDirectory();
455 | StatFs stat = new StatFs(path.getPath());
456 | long blockSize = stat.getBlockSize();
457 | long totalBlocks = stat.getBlockCount();
458 | return ConvertSize(totalBlocks * blockSize);
459 | }
460 |
461 | @SuppressWarnings("deprecation")
462 | public String getAvailableExternalMemorySize() {
463 | if (android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED)) {
464 | File path = Environment.getExternalStorageDirectory();
465 | StatFs stat = new StatFs(path.getPath());
466 | long blockSize = stat.getBlockSize();
467 | long availableBlocks = stat.getAvailableBlocks();
468 | return ConvertSize(availableBlocks * blockSize);
469 | } else {
470 | return "SDCard not present";
471 | }
472 | }
473 |
474 | @SuppressWarnings("deprecation")
475 | public String getTotalExternalMemorySize() {
476 | if (android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED)) {
477 | File path = Environment.getExternalStorageDirectory();
478 | StatFs stat = new StatFs(path.getPath());
479 | long blockSize = stat.getBlockSize();
480 | long totalBlocks = stat.getBlockCount();
481 | return ConvertSize(totalBlocks * blockSize);
482 | } else {
483 | return "SDCard not present";
484 | }
485 | }
486 | public boolean isRooted() {
487 | boolean found = false;
488 | if (!found) {
489 | String[] places = {"/sbin/", "/system/bin/", "/system/xbin/", "/data/local/xbin/",
490 | "/data/local/bin/", "/system/sd/xbin/", "/system/bin/failsafe/", "/data/local/"};
491 | for (String where : places) {
492 | if ( new File( where + "su" ).exists() ) {
493 | found = true;
494 | break;
495 | }
496 | }
497 | }
498 | return found;
499 | }
500 | @SuppressWarnings("deprecation")
501 | public String getNetworkMode(Activity act) {
502 | ConnectivityManager connMgr = (ConnectivityManager)act.getSystemService(Context.CONNECTIVITY_SERVICE);
503 | NetworkInfo wifi = connMgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
504 | NetworkInfo mobile = connMgr.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
505 | if (wifi.isConnectedOrConnecting()) {
506 | return "Wifi";
507 | }
508 | else if (mobile.isConnectedOrConnecting()) {
509 |
510 | if(Build.VERSION.SDK_INT>Build.VERSION_CODES.ECLAIR_MR1)
511 | {
512 | if(mobile.getSubtype() == TelephonyManager.NETWORK_TYPE_1xRTT)
513 | return "1xRTT";
514 | if(mobile.getSubtype() == TelephonyManager.NETWORK_TYPE_CDMA)
515 | return "CDMA";
516 | if(mobile.getSubtype() == TelephonyManager.NETWORK_TYPE_EDGE)
517 | return "EDGE";
518 | if(mobile.getSubtype() == TelephonyManager.NETWORK_TYPE_EVDO_0)
519 | return "EVDO 0";
520 | if(mobile.getSubtype() == TelephonyManager.NETWORK_TYPE_EVDO_A)
521 | return "EVDO A";
522 | if(mobile.getSubtype() == TelephonyManager.NETWORK_TYPE_GPRS)
523 | return "GPRS";
524 | if(mobile.getSubtype() == TelephonyManager.NETWORK_TYPE_HSDPA)
525 | return "HSDPA";
526 | if(mobile.getSubtype() == TelephonyManager.NETWORK_TYPE_HSPA)
527 | return "HSPA";
528 | if(mobile.getSubtype() == TelephonyManager.NETWORK_TYPE_HSUPA)
529 | return "HSUPA";
530 | if(mobile.getSubtype() == TelephonyManager.NETWORK_TYPE_UMTS)
531 | return "UMTS";
532 | if(Build.VERSION.SDK_INT>Build.VERSION_CODES.HONEYCOMB)
533 | if(mobile.getSubtype() == TelephonyManager.NETWORK_TYPE_EHRPD)
534 | return "EHRPD";
535 | if(Build.VERSION.SDK_INT>Build.VERSION_CODES.FROYO)
536 | if(mobile.getSubtype() == TelephonyManager.NETWORK_TYPE_IDEN)
537 | return "IDEN";
538 | if(Build.VERSION.SDK_INT>Build.VERSION_CODES.GINGERBREAD_MR1)
539 | if(mobile.getSubtype() == TelephonyManager.NETWORK_TYPE_EVDO_B)
540 | return "EVDO B";
541 | if(Build.VERSION.SDK_INT>Build.VERSION_CODES.HONEYCOMB)
542 | if(mobile.getSubtype() == TelephonyManager.NETWORK_TYPE_LTE)
543 | return "LTE";
544 | if(Build.VERSION.SDK_INT>Build.VERSION_CODES.HONEYCOMB_MR2)
545 | if(mobile.getSubtype() == TelephonyManager.NETWORK_TYPE_HSPAP)
546 | return "HSPAP";
547 | if(mobile.getSubtype() == TelephonyManager.NETWORK_TYPE_UNKNOWN)
548 | return "UNKNOWN";
549 | }
550 | }
551 | else
552 | {
553 | return "No Network";
554 | }
555 | return "NULL";
556 | }
557 | public boolean isSimSupport(Context context)
558 | {
559 | TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
560 | return !(tm.getSimState() == TelephonyManager.SIM_STATE_ABSENT);
561 |
562 | }
563 | }
564 |
--------------------------------------------------------------------------------