Skip to content

Commit 1bf388d

Browse files
Merge pull request amitshekhariitbhu#13 from vinayagasundar/master
Added option to set custom port number.
2 parents c272c33 + 517d9de commit 1bf388d

File tree

4 files changed

+29
-2
lines changed

4 files changed

+29
-2
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,18 @@ Now open the provided link in your browser.
3333

3434
Important : Your Android phone and laptop should be connected to the same Network (Wifi or LAN).
3535

36+
Note : If you want use different port other than 8080.
37+
In the app build.gradle file under buildTypes do the following change
38+
39+
```groovy
40+
debug {
41+
resValue("string", "PORT_NUMBER", "8081")
42+
}
43+
```
44+
45+
46+
47+
3648
You will see something like this :
3749

3850
<img src=https://raw.githubusercontent.com/amitshekhariitbhu/Android-Debug-Database/master/assets/debugdb.png >

app/build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ android {
3131
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
3232
}
3333
buildTypes {
34+
debug {
35+
resValue("string", "PORT_NUMBER", "8081")
36+
}
3437
release {
3538
minifyEnabled false
3639
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

debug-db/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ android {
3131

3232
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
3333

34+
resValue("string", "PORT_NUMBER", "8080")
3435
}
36+
3537
buildTypes {
3638
release {
3739
minifyEnabled false

debug-db/src/main/java/com/amitshekhar/DebugDB.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,19 @@ private DebugDB() {
4141
}
4242

4343
public static void initialize(Context context) {
44-
clientServer = new ClientServer(context, DEFAULT_PORT);
44+
int portNumber;
45+
46+
try {
47+
portNumber = Integer.valueOf(context.getString(R.string.PORT_NUMBER));
48+
} catch (NumberFormatException ex) {
49+
Log.e(TAG, "PORT_NUMBER should be integer", ex);
50+
portNumber = DEFAULT_PORT;
51+
Log.i(TAG, "Using Default port : " + DEFAULT_PORT);
52+
}
53+
54+
clientServer = new ClientServer(context, portNumber);
4555
clientServer.start();
46-
addressLog = NetworkUtils.getAddressLog(context, DEFAULT_PORT);
56+
addressLog = NetworkUtils.getAddressLog(context, portNumber);
4757
Log.d(TAG, addressLog);
4858
}
4959

0 commit comments

Comments
 (0)