Android Question Open chat and share text with WhatsApp

asales

Expert
Licensed User
Longtime User
I use the WhatsApp library but now the function OpenChatWithNumber don't work with WhatsApp.

In the unfiltered logs I get this error:
B4X:
Stale or unreachable neighbors, ndm state: 4
Destroying surface Surface(name=Starting com.whatsapp) called by com.android.server.wm.WindowStateAnimator.destroySurface:2069 com.android.server.wm.WindowStateAnimator.destroySurfaceLocked:897 com.android.server.wm.WindowState.destroyOrSaveSurface:2121 com.android.server.wm.AppWindowToken.destroySurfaces:368 com.android.server.wm.WindowStateAnimator.finishExit:575 com.android.server.wm.AppWindowAnimator.stepAnimationLocked:438 com.android.server.wm.WindowAnimator.updateAppWindowsLocked:176 com.android.server.wm.WindowAnimator.animateLocked:678
Failed looking up window
java.lang.IllegalArgumentException: Requested window android.view.ViewRootImpl$W@8d822a7 does not exist
    at com.android.server.wm.WindowManagerService.windowForClientLocked(WindowManagerService.java:9234)
    at com.android.server.wm.WindowManagerService.windowForClientLocked(WindowManagerService.java:9225)
    at com.android.server.wm.WindowManagerService.removeWindow(WindowManagerService.java:2366)
    at com.android.server.wm.Session.remove(Session.java:202)
    at android.view.ViewRootImpl.dispatchDetachedFromWindow(ViewRootImpl.java:3298)
    at android.view.ViewRootImpl.doDie(ViewRootImpl.java:5893)
    at android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:3634)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:154)
    at android.os.HandlerThread.run(HandlerThread.java:61)
    at com.android.server.ServiceThread.run(ServiceThread.java:46)
Thermal-Server: Thermal received msg from  override

I posted this thread with the similar issue with the WhatsApp Business, but now I have the same problem with the regular WhatsApp.

I tried this (modified) code from this thread and the WhatsApp is starteed but not in the specific phone number (I need to select the contact):
https://www.b4x.com/android/forum/t...ges-in-all-social-and-not-apps.99707/#content
B4X:
#If JAVA
import android.content.Intent;

public Intent intnt(String toNumber, String message){
   Intent i = new Intent(Intent.ACTION_SEND);
   i.setType("text/plain");
   i.putExtra(Intent.EXTRA_TEXT, message);
   i.setPackage("com.whatsapp");
   return i;
};
#End If
I saw some codes, but working only with the device connected to the internet.
My app uses the function OpenChatWithNumber of WPP Libraty to open the WhatsApp app offline and later send the messages.

Any tips to create a function to open the WhatsApp in the specific number (and optionally share text) are welcome.

Thanks in advance.
 
Top