B4A Library Manam IP Location( Get Location info )

Hi guys

It's my first library that I put it here o_O by this library you can get bellow info :

  • IP
  • ContryName
  • City
  • TimeZone
  • zip
  • lat / lon
  • ISP Name
  • Country Code
  • Region
  • Region Name
I have used the following links for the library :


Ver 1.1
  • Rewrite by OkHttpUtils2 ( Ver 2.4 )
Sample Code :

B4X:
Sub Globals
    Private man As ManamIP
    Private lv As ListView
    Private toolbar As ACToolBarLight
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("a1")
    man.Initialize("Manam" , Me)
    man.GetIPInfo
    ProgressDialogShow("Please wait...")
End Sub

Sub mnugetlocation_Click
    man.GetIPInfo
    ProgressDialogShow("Please wait...")
End Sub

Sub Manam_Ready ( result As Map , success As Boolean)
    ProgressDialogHide
    If success Then
        lv.Clear
        LogColor( result , Colors.RGB(103, 156, 203))
        For i = 0 To result.Size -1
            lv.AddSingleLine ( result.GetKeyAt(i) & " : " & result.GetValueAt(i))
        Next
    Else
        Log(LastException)
    End If
End Sub

photo-2017-01-28-21-36-21.jpg
 

Attachments

  • example.zip
    7.8 KB · Views: 413
  • lib.zip
    3.3 KB · Views: 419
  • ManamIP_ver1.1.zip
    3.3 KB · Views: 378
Last edited:

hayk

Member
Hi guys

It's my first library that I put it here o_O by this library you can get bellow info :

  • IP
  • ContryName
  • City
  • TimeZone
  • zip
  • lat / lon
  • ISP Name
  • Country Code
  • Region
  • Region Name
I have used the following links for the library :


Ver 1.1
  • Rewrite by OkHttpUtils2 ( Ver 2.4 )
Sample Code :

B4X:
Sub Globals
    Private man As ManamIP
    Private lv As ListView
    Private toolbar As ACToolBarLight
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("a1")
    man.Initialize("Manam" , Me)
    man.GetIPInfo
    ProgressDialogShow("Please wait...")
End Sub

Sub mnugetlocation_Click
    man.GetIPInfo
    ProgressDialogShow("Please wait...")
End Sub

Sub Manam_Ready ( result As Map , success As Boolean)
    ProgressDialogHide
    If success Then
        lv.Clear
        LogColor( result , Colors.RGB(103, 156, 203))
        For i = 0 To result.Size -1
            lv.AddSingleLine ( result.GetKeyAt(i) & " : " & result.GetValueAt(i))
        Next
    Else
        Log(LastException)
    End If
End Sub

photo-2017-01-28-21-36-21.jpg

I am getting this error. What is the problem?


error:
Logger connected to:  YUSUNOUL GT80
--------- beginning of main
java.lang.RuntimeException: Unable to start activity ComponentInfo{b4a.example.maanamlocationbyIp/b4a.example.maanamlocationbyIp.main}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3675)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3832)
    at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103)
    at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2247)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loopOnce(Looper.java:201)
    at android.os.Looper.loop(Looper.java:288)
    at android.app.ActivityThread.main(ActivityThread.java:7881)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:568)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1045)
Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
    at androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor(AppCompatDelegateImpl.java:856)
    at androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor(AppCompatDelegateImpl.java:819)
    at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:698)
    at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:201)
    at b4a.example.maanamlocationbyIp.main.onCreate(main.java:62)
    at android.app.Activity.performCreate(Activity.java:8050)
    at android.app.Activity.performCreate(Activity.java:8030)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1329)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3648)
    ... 12 more
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
Activity_Create Error! (ClassCastException) java.lang.ClassCastException: b4a.example.maanamlocationbyIp.main cannot be cast to androidx.appcompat.app.AppCompatActivity
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
** Activity (main) Resume **
*** Service (httputils2service) Create ***
java.lang.NoClassDefFoundError: Failed resolution of: Lokhttp3/JavaNetCookieJar;
    at anywheresoftware.b4h.okhttp.OkHttpClientWrapper.sharedInit(OkHttpClientWrapper.java:136)
    at anywheresoftware.b4h.okhttp.OkHttpClientWrapper.Initialize(OkHttpClientWrapper.java:94)
    at anywheresoftware.b4a.samples.httputils2.httputils2service._service_create(httputils2service.java:227)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:221)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:201)
    at anywheresoftware.b4a.samples.httputils2.httputils2service.onCreate(httputils2service.java:56)
    at android.app.ActivityThread.handleCreateService(ActivityThread.java:4527)
    at android.app.ActivityThread.access$1800(ActivityThread.java:253)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2109)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loopOnce(Looper.java:201)
    at android.os.Looper.loop(Looper.java:288)
    at android.app.ActivityThread.main(ActivityThread.java:7881)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:568)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1045)
Caused by: java.lang.ClassNotFoundException: okhttp3.JavaNetCookieJar
    ... 17 more
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
** Activity (main) Resume **
*** Service (httputils2service) Create ***
java.lang.NoClassDefFoundError: Failed resolution of: Lokhttp3/JavaNetCookieJar;
    at anywheresoftware.b4h.okhttp.OkHttpClientWrapper.sharedInit(OkHttpClientWrapper.java:136)
    at anywheresoftware.b4h.okhttp.OkHttpClientWrapper.Initialize(OkHttpClientWrapper.java:94)
    at anywheresoftware.b4a.samples.httputils2.httputils2service._service_create(httputils2service.java:227)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:221)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:201)
    at anywheresoftware.b4a.samples.httputils2.httputils2service.onCreate(httputils2service.java:56)
    at android.app.ActivityThread.handleCreateService(ActivityThread.java:4527)
    at android.app.ActivityThread.access$1800(ActivityThread.java:253)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2109)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loopOnce(Looper.java:201)
    at android.os.Looper.loop(Looper.java:288)
    at android.app.ActivityThread.main(ActivityThread.java:7881)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:568)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1045)
Caused by: java.lang.ClassNotFoundException: okhttp3.JavaNetCookieJar
    ... 17 more
*** Service (httputils2service) Create ***
java.lang.NoClassDefFoundError: Failed resolution of: Lokhttp3/JavaNetCookieJar;
    at anywheresoftware.b4h.okhttp.OkHttpClientWrapper.sharedInit(OkHttpClientWrapper.java:136)
    at anywheresoftware.b4h.okhttp.OkHttpClientWrapper.Initialize(OkHttpClientWrapper.java:94)
    at anywheresoftware.b4a.samples.httputils2.httputils2service._service_create(httputils2service.java:227)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:221)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:201)
    at anywheresoftware.b4a.samples.httputils2.httputils2service.onCreate(httputils2service.java:56)
    at android.app.ActivityThread.handleCreateService(ActivityThread.java:4527)
    at android.app.ActivityThread.access$1800(ActivityThread.java:253)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2109)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loopOnce(Looper.java:201)
    at android.os.Looper.loop(Looper.java:288)
    at android.app.ActivityThread.main(ActivityThread.java:7881)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:568)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1045)
Caused by: java.lang.ClassNotFoundException: okhttp3.JavaNetCookieJar
    ... 17 more
java.lang.NoClassDefFoundError: Failed resolution of: Lokhttp3/JavaNetCookieJar;
    at anywheresoftware.b4h.okhttp.OkHttpClientWrapper.sharedInit(OkHttpClientWrapper.java:136)
    at anywheresoftware.b4h.okhttp.OkHttpClientWrapper.Initialize(OkHttpClientWrapper.java:94)
    at anywheresoftware.b4a.samples.httputils2.httputils2service._service_create(httputils2service.java:227)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:221)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:201)
    at anywheresoftware.b4a.samples.httputils2.httputils2service.onCreate(httputils2service.java:56)
    at android.app.ActivityThread.handleCreateService(ActivityThread.java:4527)
    at android.app.ActivityThread.access$1800(ActivityThread.java:253)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2109)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loopOnce(Looper.java:201)
    at android.os.Looper.loop(Looper.java:288)
    at android.app.ActivityThread.main(ActivityThread.java:7881)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:568)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1045)
Caused by: java.lang.ClassNotFoundException: okhttp3.JavaNetCookieJar
    ... 17 more
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
** Activity (main) Resume **
*** Service (httputils2service) Create ***
java.lang.NoClassDefFoundError: Failed resolution of: Lokhttp3/JavaNetCookieJar;
    at anywheresoftware.b4h.okhttp.OkHttpClientWrapper.sharedInit(OkHttpClientWrapper.java:136)
    at anywheresoftware.b4h.okhttp.OkHttpClientWrapper.Initialize(OkHttpClientWrapper.java:94)
    at anywheresoftware.b4a.samples.httputils2.httputils2service._service_create(httputils2service.java:227)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:221)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:201)
    at anywheresoftware.b4a.samples.httputils2.httputils2service.onCreate(httputils2service.java:56)
    at android.app.ActivityThread.handleCreateService(ActivityThread.java:4527)
    at android.app.ActivityThread.access$1800(ActivityThread.java:253)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2109)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loopOnce(Looper.java:201)
    at android.os.Looper.loop(Looper.java:288)
    at android.app.ActivityThread.main(ActivityThread.java:7881)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:568)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1045)
Caused by: java.lang.ClassNotFoundException: okhttp3.JavaNetCookieJar
    ... 17 more
 
Top