1

我已经成功注册了微信。我现在想向微信发送消息,但我发生了:

[ERROR] E/MicroMsg.SDK.MMessageAct: send fail, target ActivityNotFound

这是我的 android 模块(src/ / .java)代码:

 @Kroll.method
  public void regToWx()
  {
    Log.d(current_module, "=======start to register to wechat==========");
    api = WXAPIFactory.createWXAPI(getActivity(),null);
    Log.d(current_module, "=======create api after====="+api);
    api.registerApp(APP_ID);
    Log.d(current_module, "====注册微信成功======");
  }
  @Kroll.method
  public void sendMessageToWx()
  {
    Log.d(current_module, "====下面发送消息给微信======");
    WXTextObject text_obj = new WXTextObject();
    text_obj.text="we are young!!!";
    Log.d(current_module, "====构造Media Message======");
    WXMediaMessage msg_obj = new WXMediaMessage();
    msg_obj.mediaObject = text_obj;
    msg_obj.description = "this is desciption";
    Log.d(current_module, "====构造 Request======");
    SendMessageToWX.Req req = new SendMessageToWX.Req();
    req.transaction = String.valueOf(System.currentTimeMillis());
    req.message = msg_obj;
    req.scene = SendMessageToWX.Req.WXSceneTimeline;
    Log.d(current_module, "====发送请求给微信了======");
    boolean result = api.sendReq(req);
    Log.d(current_module, "====result======"+result);
    Activity activity = TiApplication.getInstance().getCurrentActivity();
    Log.d(current_module, activity.toString());
  }

这是我的 test_app

<activity android:name="com.happysoft.testmodule.TestModuleModule" android:exported="true" android:label="@string/app_name"></activity>
4

1 回答 1

0

我解决了这个麻烦。

@Kroll.onAppCreate
  public static void onAppCreate(TiApplication app)
  {
    Log.d(LCAT, "inside onAppCreate");
    api = WXAPIFactory.createWXAPI(app,APP_ID,true);
    api.registerApp(APP_ID);
    Log.d(LCAT, "================= register App success=====================");

  }
于 2015-03-28T03:08:54.013 回答