Android Question Chat B4A

MarcoRome

Expert
Licensed User
Longtime User
i found this interesting code that Integrated live chat for mobile apps.
https://www.hipmob.com/



This is code to integration Chat:




In attachment library android-hipmob-2.9.8.jar


So i created new project in manifest i add this:
B4X:
'See this link for for more information: https://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="14"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>
    <intent-filter>
    <action android:name="com.hipmob.android.HipmobCore"/>
    </intent-filter>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
SetApplicationAttribute(android:theme, "@android:style/Theme.Light")
'End of default text.
AddPermission("android.permission.INTERNET")
AddPermission("android.permission.WRITE_EXTERNAL_STORAGE")
AddPermission("android.permission.RECORD_AUDIO")


and in my code i add this:

#AdditionalJar: android-hipmob-2.9.8 'Copy this jat in library folder

B4X:
 Dim i As Intent
i.Initialize("com.hipmob.android.HipmobCore.class", "")
i.PutExtra("HipmobCore.KEY_APPID", "2f6524fbfe9d4ae482a3deadf5a0563a")
i.PutExtra("HipmobCore.KEY_USERID", "<userid>")
i.PutExtra("HipmobCore.KEY_TITLE", "First app (devilapp): Chat")
StartActivity(i)


And i have this error: ancroid.content.ActivityNotFoundException: No Activity found to handle intent ..... dat=com.hipmob.android.HipmodCore.class flg=0x200000 ( has extras)


Where i wrong ?
thank you
Marco
 

Attachments

  • android-hipmob-2.9.8.jar
    248.1 KB · Views: 265
Last edited:

MarcoRome

Expert
Licensed User
Longtime User
Someone know as translate this in B4A:

This in Manifest
B4X:
Add the HipmobCore activity definition to the AndroidManifest.xml file.
<activity android:name="com.hipmob.android.HipmobCore" android:theme="@android:style/Theme.Light" />

and this intent:

B4X:
Intent i = new Intent(this, com.hipmob.android.HipmobCore.class);
i.putExtra(HipmobCore.KEY_APPID, "2f6524fbfe9d4ae482a3deadf5a0563a");
i.putExtra(HipmobCore.KEY_USERID, "<userid>");
i.putExtra(HipmobCore.KEY_TITLE, "First app (devilapp): Chat");
startActivity(i);

Thank you
Marco
 
Upvote 0

MarcoRome

Expert
Licensed User
Longtime User

Hi Erel.
Pls, can you help me translate this code in B4A ?
Thank you very much
Marco
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
You need to use the constants values instead of the names.

If you don't find the values in the documentation then you can use JavaObject to get the value:
B4X:
Sub GetConstantValue(ClassName, FieldName) As Object
 Dim jo As JavaObject
return  jo.InitializeStatic(ClassName).GetField(FieldName)
End Sub

B4X:
i.PutExtra(GetConstantValue("com.hipmob.android.HipmobCore", "KEY_APPID"), ...)
 
Upvote 0

MarcoRome

Expert
Licensed User
Longtime User

Thank you Erel for your response.
But anyway dont work. This is my code:

B4X:
#Region  Project Attributes
    #ApplicationLabel: B4A Chat
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
    #AdditionalJar: android-hipmob-2.9.8
#End Region
 
#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region
 
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
 
End Sub
 
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
 
End Sub
 
Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")
Dim i As Intent
i.Initialize("com.hipmob.android.HipmobCore.class", "")
'i.Initialize(GetConstantValue("com.hipmob.android.HipmobCore", "com.hipmob.android.HipmobCore.class"), "")
'i.Initialize("com.hipmob.android.HipmobCore", "")
i.PutExtra(GetConstantValue("com.hipmob.android.HipmobCore", "KEY_APPID"), "2f6524fbfe9d4ae482a3deadf5a0963a" )
i.PutExtra(GetConstantValue("com.hipmob.android.HipmobCore", "KEY_USERID"), "<userid>")
i.PutExtra(GetConstantValue("com.hipmob.android.HipmobCore", "KEY_TITLE"), "First app (devilapp): Chat")
StartActivity(i)
 
End Sub
 
 
 
Sub GetConstantValue(ClassName, FieldName) As Object
Dim jo As JavaObject
Return  jo.InitializeStatic(ClassName).GetField(FieldName)
End Sub
 
Sub Activity_Resume
 
End Sub
 
Sub Activity_Pause (UserClosed As Boolean)
 
End Sub

This is my Manifest:
B4X:
AddManifestText(
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="14"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
AddActivityText(Main, <intent-filter>
   <action android:name="com.hipmob.android.HipmobCore" />
</intent-filter>)  
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
SetApplicationAttribute(android:theme, "@android:style/Theme.Holo")
'End of default text.
AddPermission("android.permission.INTERNET")
AddPermission("android.permission.WRITE_EXTERNAL_STORAGE")
AddPermission("android.permission.RECORD_AUDIO")

In attachment project.

Where i wrong ?
Thank you again for your support.
Marco
 

Attachments

  • ChatB4A.zip
    8.6 KB · Views: 268
Upvote 0

MarcoRome

Expert
Licensed User
Longtime User
Erel dont work also so, i try:

B4X:
i.Initialize("com.hipmob.android.HipmobCore", "")
'i.Initialize(GetConstantValue("com.hipmob.android.HipmobCore", "com.hipmob.android.HipmobCore.class"), "")
'i.Initialize("com.hipmob.android.HipmobCore", "")
i.PutExtra(GetConstantValue("com.hipmob.android.HipmobCore", "KEY_APPID"), "2f6524fbfe9d4ae482a3deadf5a0963a" )
i.PutExtra(GetConstantValue("com.hipmob.android.HipmobCore", "KEY_USERID"), "<userid>")
i.PutExtra(GetConstantValue("com.hipmob.android.HipmobCore", "KEY_TITLE"), "First app (devilapp): Chat")
i.SetComponent("/.com.hipmob.android.HipmobCore")
StartActivity(i)

B4X:
i.Initialize("", "")
'i.Initialize(GetConstantValue("com.hipmob.android.HipmobCore", "com.hipmob.android.HipmobCore.class"), "")
'i.Initialize("com.hipmob.android.HipmobCore", "")
i.PutExtra(GetConstantValue("com.hipmob.android.HipmobCore", "KEY_APPID"), "2f6524fbfe9d4ae482a3deadf5a0963a" )
i.PutExtra(GetConstantValue("com.hipmob.android.HipmobCore", "KEY_USERID"), "<userid>")
i.PutExtra(GetConstantValue("com.hipmob.android.HipmobCore", "KEY_TITLE"), "First app (devilapp): Chat")
i.SetComponent("/.com.hipmob.android.HipmobCore")
StartActivity(i)

But the result is:
android.content.ActivityNot Found Exception: Unable to find explicit activity class /.com.hipmod.android.Hipmobcore

Another idea ?
Thank you
Marco
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
in manifest i add this
And you think this is enough? When i look at the example project from them i see A LOT more to add in the manifest!?

As far as i can see it must be something like
 
Upvote 0

MarcoRome

Expert
Licensed User
Longtime User
After a "few" time i comeback for resolve this.

Implement this "seem very simple":



So i insert in my code this steps.

Manifest.xml

B4X:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: https://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="14"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
AddActivityText(Main, <intent-filter>
   <action android:name="com.hipmob.android.HipmobCore" />
</intent-filter>) 
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
SetApplicationAttribute(android:theme, "@android:style/Theme.Holo")
'End of default text.
AddPermission("android.permission.INTERNET")
AddPermission("android.permission.WRITE_EXTERNAL_STORAGE")
AddPermission("android.permission.RECORD_AUDIO")

In my code Main this:

B4X:
#Region  Project Attributes
    #ApplicationLabel: First app (marcoamici)
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
    #AdditionalJar: android-hipmob-2.9.8
#End Region

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.

End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")
Dim i As Intent
i.Initialize("com.hipmob.android.HipmobCore.class", "")
'i.SetComponent(Application.PackageName & "/com.hipmob.android.HipmobCore")
'i.SetComponent("com.hipmob.android/.HipmobCore.class")
i.PutExtra(GetConstantValue("com.hipmob.android.HipmobCore", "KEY_APPID"), "f994a48f7a544911b27c596451dfd2e6" )
i.PutExtra(GetConstantValue("com.hipmob.android.HipmobCore", "KEY_USERID"), "<userid>")
i.PutExtra(GetConstantValue("com.hipmob.android.HipmobCore", "KEY_TITLE"), "First app (devilapp): Chat")
StartActivity(i)

End Sub



Sub GetConstantValue(ClassName, FieldName) As Object
Dim jo As JavaObject
Return  jo.InitializeStatic(ClassName).GetField(FieldName)
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Now i receive this error:



Also if in jar i have this:



In attachment Project and Jar
Any idea ???
Thank you
Regards
Marco
 

Attachments

  • HipModeDemoChat.zip
    8.3 KB · Views: 230
  • android-hipmob-2.9.8.jar
    248.2 KB · Views: 246
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…