I am working on android wear app using Eclipse IDE.I am using same package names for wear app and mobile app and i am packing wearable app manually according to google documentation.Everything is working fine.it is installed on Android wear emulator using usb debugging with phone.
My problem is when i am sending a message to wearable using following code
List<Node> nodeList=getNodes();
for(Node node : nodeList) {
Log.v(" ", "telling " + node.getId() );
PendingResult<MessageApi.SendMessageResult> result = Wearable.MessageApi.sendMessage(
mGoogleApiClient,
node.getId(),
START_ACTIVITY_PATH,
null
);
result.setResultCallback(new ResultCallback<MessageApi.SendMessageResult>() {
#Override
public void onResult(MessageApi.SendMessageResult sendMessageResult) {
Log.v(" ", "Phone: " + sendMessageResult.getStatus().getStatusMessage());
}
});
}
the OnPeerConnected method is running when devices are peered but OnMessageReceived never called in WearableListenerService.This is my WearableListenerService code:
public class DataLayerListenerService extends WearableListenerService {
private static final String TAG = "DataLayerSample";
private static final String START_ACTIVITY_PATH = "/start/MainActivity";
private static final String DATA_ITEM_RECEIVED_PATH = "/data-item-received";
private static final String LOG_TAG = "log";
#Override
public void onPeerConnected(Node peer) {
super.onPeerConnected(peer);
String id = peer.getId();
String name = peer.getDisplayName();
Log.d(LOG_TAG, "Connected peer name & ID: " + name + "|" + id);
}
#Override
public void onDataChanged(DataEventBuffer dataEvents) {
System.out.println("Recevive message3");
}
#Override
public void onMessageReceived(MessageEvent messageEvent) {
System.out.println("service watch message1");
if (messageEvent.getPath().equals(START_ACTIVITY_PATH)) {
System.out.println("service watch message2");
Intent startIntent = new Intent(this, MainActivity.class);
startIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(startIntent);
}
}
}
Also a warning message in Logcat always appears :
app does not match record's app key: AppKey[com.myapp,c3f31717fa35401056c20a2798907f1232efa75e] != AppKey[com.myapp,f36e726eefc7e528db26a1c25f6fbf2f93dacd70]
If app key for both apps should be same then how can i create same app key for both the apps.
Any help is highly appreciated,
Thanks.
The error message you have:
app does not match record's app key:
AppKey[com.myapp,c3f31717fa35401056c20a2798907f1232efa75e] !=
AppKey[com.myapp,f36e726eefc7e528db26a1c25f6fbf2f93dacd70]
Indicated that your apps are signed with the different keys.
Package names of phone and wearable apps are the same - that is good, but they also need to share the same signature. This is the reason why messages cannot be delivered - wearable apps are recognized as "part of the same app" based on the package name and signature.
Please make sure that you have both apps signed with the same key. If you are testing the autoinstallation feature please make sure to uninstall the debug version of wearable app from watch emulator.
I had the same error, my fault was that the "wear" module's package name was not the same as the app's.
BAD:
[module: app] es.voghdev.myapp
[module: wear] es.voghdev.myapp.wear
GOOD:
[module: app] es.voghdev.myapp
[module: wear] es.voghdev.myapp
Made me waste so much time!! >:-(
Use an asyntask to send messages as they will block the ui thread. Also you need to call the await method. To get the apps to have the same key, you need to use build variants with gradle.
public class SendMessageTask extends AsyncTask<Void, Void, Void> {
#Override
protected Void doInBackground(Void... voids) {
NodeApi.GetConnectedNodesResult nodes =
Wearable.NodeApi.getConnectedNodes(apiClient).await();
for (Node node : nodes.getNodes()) {
Wearable.MessageApi
.sendMessage(apiClient, node.getId(), "/start/MainActivity", null)
.await();
}
return null;
}
#Override
protected void onPostExecute(Void aVoid) {
super.onPostExecute(aVoid);
Toast.makeText(MainActivity.this, "Message Sent", Toast.LENGTH_SHORT).show();
}
}
Related
I have written a bound service and I would like this service to be only called from particular app. I do not want other apps to be able to make calls to this service.
The options I know so far are:
Use a permission. There seems to be 3 secured permission, dangerous, signature and signatureOrSystem. Unfortunately, none of these permissions will work for me as I don't want users to accept this permission also both app does not have same signature and these are not system app.
Get app name on service bind or when making a call to service. I looked up a way to do this on stackoverflow here. This unfortunately does not works for me as it always returns the app ID in which the service resides.
Is there any other option for me or I can use the above mentioned options with some change to achieve the desired requirement.
Bound Service Code
public class SampleCommsService extends Service {
private static Messenger messanger;
#Override
public IBinder onBind(Intent intent) {
Log.e("TEST", "package intent: " + intent.getPackage());
String callingApp = MyApplication.getAppContext().getPackageManager().getNameForUid(Binder.getCallingUid());
Log.e("TEST", "onBind - package name: " + callingApp);
return getMyBinder();
}
private synchronized IBinder getMyBinder() {
if (messanger == null) {
messanger = new Messenger(new SettingsProcessor());
}
return messanger.getBinder();
}
class SettingsProcessor extends Handler {
private static final int GET_SETTINGS_REQUEST = 1;
private static final int UPDATE_SETTINGS_RESPONSE = 2;
private static final String SETTINGS = "settings";
#Override
public void handleMessage(Message msg) {
String callingApp = MyApplication.getAppContext().getPackageManager().getNameForUid(Binder.getCallingUid());
Log.e("TEST", "handle message - package name: " + callingApp);
switch (msg.what) {
case GET_SETTINGS_REQUEST:
sendSettingsValue(msg);
break;
default:
super.handleMessage(msg);
}
}
private void sendSettingsValue(Message msg) {
try {
Message resp = Message.obtain(null, UPDATE_SETTINGS_RESPONSE);
Bundle bundle = new Bundle();
bundle.putBoolean(SETTINGS, MyApplication.isSettingsEnabled());
resp.setData(bundle);
msg.replyTo.send(resp);
} catch (RemoteException e) {
// ignore
}
}
}
}
Output on calling api:
02-01 15:21:03.138 7704-7704/my.service.package E/TEST: package intent: null
02-01 15:21:03.139 7704-7704/my.service.package E/TEST: onBind - package name: my.service.package
02-01 15:21:12.429 7704-7704/my.service.package E/TEST: handle message - package name: my.service.package
OK, I was able to solve this problem based on a given answer here. The answer given in the link obviously does not works, but you can get the app ID from the Handler used for the bound service.
class SettingsProcessor extends Handler {
#Override
public void handleMessage(Message msg) {
String callingApp = MyApplication.getAppContext().getPackageManager().getNameForUid(msg.sendingUid);
Log.e("TEST", "handle message - package name: " + callingApp);
}
}
Instead of Binder.getCallingUid(), I am using msg.sendingUid and it works fine for me.
I'm trying to implement WeChat InApp payments in our app. But we are struggling to make it work.
I will try to sum it up real quick.
Given user is not logged in, WeChat login screen show up every time.
Given user is logged in, when clicked on pay button for a first time, WeChat order info screen shows up, but when clicked back, and clicked on pay button again (in our app), WeChat screen doesn’t show up.
We did implemented WXPayEntryActivity but neither onCreate, onNewIntent nor onResp are called. And yes, this activity is sending broadcast but neither toast nor log shows up.
I tried call registerApp on application started, I tried it just before creating payment req.
Did anybody come across this issue?
Can WeChat help me directly?
Want to see some code?
This is my payment class
public class WXInAppPayment {
public void startPayment(AppCompatActivity activity, PaymentDataResponse data) {
IWXAPI api = getApi(activity);
if (api.isWXAppInstalled()) {
api.sendReq(getPayRequest(data));
} else {
// Showing toast
}
}
public WXReceiver getReceiver() {
// returning BR for wechat payments
return new WXReceiver();
}
public IntentFilter getIntentFilter() {
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(Constants.WE_CHAT_BR_ID);
return intentFilter;
}
private IWXAPI getApi(AppCompatActivity activity) {
final IWXAPI api = WXAPIFactory.createWXAPI(activity, null);
api.registerApp(Constants.WE_CHAT_APP_ID);
return api;
}
private PayReq getPayRequest(PaymentDataResponse data) {
PayReq request = new PayReq();
request.appId = dataFromAPI.appId;
request.partnerId = dataFromAPI.partnerId;
request.prepayId = dataFromAPI.prepayId;
request.packageValue = dataFromAPI.packageValue;
request.nonceStr = dataFromAPI.nonceStr;
request.timeStamp = dataFromAPI.timestimeStampamp;
request.sign = dataFromAPI.sign;
return request;
}
}
And this is WXPayEntryActivity. In manifest:
<activity android:name=".wxapi.WXPayEntryActivity"
android:label="#string/app_name"
android:exported="true"/>
And class:
public class WXPayEntryActivity extends Activity implements IWXAPIEventHandler {
private final String TAG = getClass().getSimpleName();
private IWXAPI api;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
api = WXAPIFactory.createWXAPI(this, Constants.WE_CHAT_APP_ID);
api.handleIntent(getIntent(), this);
}
#Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
setIntent(intent);
api.handleIntent(intent, this);
}
#Override
public void onReq(BaseReq baseReq) {
Log.e(TAG, "onReq: " + baseReq.transaction);
}
#Override
public void onResp(BaseResp baseResp) {
Log.e(TAG, "onResp: " + baseResp.errStr + " " + baseResp.errCode);
Intent intent = new Intent(Constants.WE_CHAT_BR_ID);
intent.putExtra("error_code", baseResp.errCode);
intent.putExtra("error_string", baseResp.errStr);
sendBroadcast(intent);
finish();
}
}
I went through same issue... Your code look fine.
lets cover the scenario:
This is normal ... if user is not logged in.. Wechat App will
redirect to login screen
"Only first time payment passed" happened due to wrong packageName. consider these checks:
You need to use ApplicationId not packageName
WhiteSpace
Debug buildType by default has suffix: .debug to applicatonId
Check AppSign which is MD5 of cert you sign with.. Be careful not to use the default one for debug buildType.
Try to reassign ApplicationId and AppSign it again.(that was our issue 😞) due to hidden WS not visible.
Contact Wechat team support.. they have logs to payment.
I am working on the udacity wearable course and unable to get my wearable emulator to send dataEvents to the wearable device.
On both the handheld and the wearable I have services that extend the WearableListenerService (WLS). The handheld version is currently started via a startService call in the activity, the wearable service is started in the watchface service also with startService, both services can be seen as started.
The device WLS successfully makes a call to the content provider and attempts at sending the data to the wearable, but putDataItem resultCallback is never called.
The wearable seems to be paired with my phone as I receive various notifications on it from my phone, so the setup is good. Both the handheld and wearable modules have the service added to the manifest with the required intent-filter, and with logging I can see they are both starting up as expected.
I am following the docs, but I must be missing something.
Thanks for any help.
Handheld service
public class WeatherDataService extends WearableListenerService implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener {
private static final String TAG = "HandheldService";
private GoogleApiClient mGoogleClientApi;
#Override
public void onCreate() {
super.onCreate();
Log.d(TAG, "initializing");
mGoogleClientApi = new GoogleApiClient.Builder(this)
.addApi(Wearable.API)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build();
mGoogleClientApi.connect();
}
#Override
public void onPeerConnected(Node peer) {
super.onPeerConnected(peer);
Log.d(TAG, "onPeerConnected: " + peer.getDisplayName());
String[] temps = getCurrentTemps();
if (temps != null && temps.length == 2) {
Log.d(TAG, String.format("onPeerConnected: temps %s %s", temps[0], temps[1]));
notifyWearables(mGoogleClientApi, temps[0], temps[1]);
}
}
private void notifyWearables(GoogleApiClient client, String low, String high) {
Log.d(TAG, String.format("notifyWearables: %s %s", low, high));
PutDataMapRequest map = PutDataMapRequest.create("/weather");
map.getDataMap().putString("tempLow", low);
map.getDataMap().putString("tempHigh", high);
PutDataRequest request = map.asPutDataRequest();
Wearable.DataApi.putDataItem(client, request).setResultCallback(new ResultCallback<DataApi.DataItemResult>() {
#Override
public void onResult(DataApi.DataItemResult result) {
Log.d(TAG, String.format("onResult, %s", result.getStatus().getStatusMessage()));
if (!result.getStatus().isSuccess()) {
Log.d(TAG, "onResult: Failed to send data");
}
}
});
...
}
Wearable service
public class WeatherDataService extends WearableListenerService {
private static final String TAG = "Wearable:Service";
#Override
public void onCreate() {
super.onCreate();
// this is called
Log.d(TAG, "onCreate");
}
#Override
public void onDataChanged(DataEventBuffer dataEvents) {
// NEVER makes it here
Log.d(TAG, "onDataChanged: ");
for (DataEvent dataEvent : dataEvents) {
Log.d(TAG, "onDataChanged: " + dataEvent.getDataItem().getUri().getPath());
if (dataEvent.getType() == DataEvent.TYPE_CHANGED) {
Log.d(TAG, "onDataChanged: TYPE_CHANGED");
DataMap dataMap = DataMapItem.fromDataItem(dataEvent.getDataItem()).getDataMap();
String path = dataEvent.getDataItem().getUri().getPath();
if (path.equals("/weather")) {
Log.d(TAG, "onDataChanged: /weather");
String tempLow = dataMap.getString("tempLow");
String tempHigh = dataMap.getString("tempHigh");
Log.d(TAG, "onDataChanged: " + tempLow + " " + tempHigh);
}
}
}
}
}
Update
I was missing the mGoogleApiClient.connect() method call. The putDataItem resultCallback is now being called, unforunately the wearable device's onDataChanged event is not being called.
onDataChanged
doesn't call because you doesn't change any data that sent to wear every time(it's call only when the data really did change), try to send different data and it will work, and make sure to connect your mGoogleClientApi
in onStrart();
It turned out there was a couple things wrong with things.
The first was what #mahmoud mentioned, although I missed it the first time I read it, in that mGoogleClientApi.connect() needed to be called. When #mahmoud said connect to the client in onStart() I didn't read that as call the .connect() method.
The second things that was wrong was that the manifest package attributes did not match for each the modules. I thought they needed the same parent namespaces.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.sunshine.app">
How can I run a Xamarin.Forms.Platform.Android.FormsApplicationActivity on an Android Wear device? The call base.OnCreate(bundle) inside the onCreate method of my class always throws a RuntimeException "You cannot use indeterminate progress on a watch".
Here is my code:
namespace Test
{
[Activity (Label = "Temp.Droid", Icon = "#drawable/icon", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsApplicationActivity
{
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
global::Xamarin.Forms.Forms.Init (this, bundle);
LoadApplication (new App ());
}
}
}
The implementation of App should not matter since the exception gets already thrown on the call of the super onCreate and not by calling LoadApplication (new App ()) for loading the application. However its the base implementation generated by the project wizard for a Xamarin Mobile Application.
Despite the answer of James Montemagno I discovered it is possible to sync data in Xamarin Forms. I used the method of Vincent Maverick and incorporated it in Xamarin Forms. First of all take care you have the right Android SDK installed (Android Wear Tutorial - A Comprehensive Introduction).
Assuming you hve your standard app, it is advised to create Wear app in a separate Xamarin Forms Cross Platform application. This because the Wear sizes are different from Phone sizes.
In both you Wear app and your phone app right click on the References of your Android project and select MANAGE NUGET PACKAGES. Browse for wear and select
Xamarin.GooglePlayServices.Wearable Version 29.0.0 (higher versions give problems).
Click on the Properties of your Android project in both applications. Make sure the Default Namespace (Application tab) and Package name (Android Manifest tab) are the same. Also make sure the Package name does not have capitals, this will cause problems in releasing your app to the Android store.
Change the value of "Compile using Android version" to "API Level 21 (Xamarin.Android v5.0 Support).
In your Android MainActivity of both projects add usings
using Android.Gms.Wearable;
using Android.Gms.Common.Apis;
using Android.Support.V4.Content;
Then change your MainActivity of both applications to the following:
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity, IDataApiDataListener, IMessageApiMessageListener
{
private static GoogleApiClient client;
const string _syncPath = "/MySyncPath/Data";
static string device = "Watch";
static string text= "";
protected override void OnCreate(Bundle bundle)
{
TabLayoutResource = Resource.Layout.Tabbar;
ToolbarResource = Resource.Layout.Toolbar;
base.OnCreate(bundle);
global::Xamarin.Forms.Forms.Init(this, bundle);
LoadApplication(new App());
client = new GoogleApiClient.Builder(this)
.AddApi(WearableClass.API)
.Build();
IntentFilter filter = new IntentFilter(Intent.ActionSend);
MessageReciever receiver = new MessageReciever(this);
LocalBroadcastManager.GetInstance(this).RegisterReceiver(receiver, filter);
}
internal class MessageReciever : BroadcastReceiver
{
MainActivity _main;
public MessageReciever(MainActivity owner) { this._main = owner; }
public override void OnReceive(Context context, Intent intent)
{
_main.ProcessMessage(intent);
}
}
public void OnDataChanged(DataEventBuffer dataEvents)
{
var dataEvent = Enumerable.Range(0, dataEvents.Count)
.Select(i => dataEvents.Get(i).JavaCast<IDataEvent>())
.FirstOrDefault(x => x.Type == DataEvent.TypeChanged && x.DataItem.Uri.Path.Equals(_syncPath));
if (dataEvent == null)
return;
//do stuffs here
}
public override void OnBackPressed()
{
base.OnBackPressed();
}
protected override void OnStart()
{
base.OnStart();
Android.Util.Log.Info("WearIntegration", "Received Message");
client.Connect();
}
public void OnConnected(Bundle p0)
{
WearableClass.DataApi.AddListener(client, this);
}
public void OnConnectionSuspended(int reason)
{
Android.Util.Log.Error("GMSonnection suspended " + reason, "");
WearableClass.DataApi.RemoveListener(client, this);
}
public void OnConnectionFailed(Android.Gms.Common.ConnectionResult result)
{
Android.Util.Log.Error("GMSonnection failed " + result.ErrorCode, "");
}
protected override void OnStop()
{
base.OnStop();
client.Disconnect();
}
public void OnMessageReceived(IMessageEvent messageEvent)
{
if (messageEvent.Path.Equals(_syncPath))
{
var msg = System.Text.Encoding.UTF8.GetString(messageEvent.GetData());
this.RunOnUiThread(() =>
Android.Widget.Toast.MakeText(this, msg, ToastLength.Long).Show());
}
}
public void ProcessMessage(Intent intent)
{
if (intent.GetStringExtra("Device") != device)
{
text = intent.GetStringExtra("WearMessage");
//do stuffs here
}
}
public void SendData() {
try {
var request = PutDataMapRequest.Create(_syncPath);
var map = request.DataMap;
map.PutString("Device", device);
map.PutString("Message", "Xamarin Forms says Hello from Wearable!");
map.PutLong("UpdatedAt", DateTime.UtcNow.Ticks);
WearableClass.DataApi.PutDataItem(_client, request.AsPutDataRequest());
}
finally {
_client.Disconnect();
}
}
In your Phone application change the static string device to Phone and change the message text if you want to:
static string device = "Phone";
map.PutString("Message", "Xamarin Forms says Hello from Phone!");
Then add the WearService class to both your Android Projects add the same usings as added to the MAinActivity an change the Wearservice as follows:
[Service]
[IntentFilter(new[] { "com.google.android.gms.wearable.BIND_LISTENER" })]
public class WearService : WearableListenerService
{
const string _syncPath = "/KorfballTimer/Data";
GoogleApiClient _client;
public override void OnCreate()
{
base.OnCreate();
_client = new GoogleApiClient.Builder(this.ApplicationContext)
.AddApi(WearableClass.API)
.Build();
_client.Connect();
Android.Util.Log.Info("WearIntegrationreated", "");
}
public override void OnDataChanged(DataEventBuffer dataEvents)
{
var dataEvent = Enumerable.Range(0, dataEvents.Count)
.Select(i => dataEvents.Get(i).JavaCast<IDataEvent)
.FirstOrDefault(x => x.Type == DataEvent.TypeChanged && x.DataItem.Uri.Path.Equals(_syncPath));
if (dataEvent == null)
return;
//get data from wearable
var dataMapItem = DataMapItem.FromDataItem(dataEvent.DataItem);
var map = dataMapItem.DataMap;
string message = dataMapItem.DataMap.GetString("Message");
Intent intent = new Intent();
intent.SetAction(Intent.ActionSend);
intent.PutExtra("WearMessage", message);
intent.PutExtra("Device", map.GetString("Device"));
LocalBroadcastManager.GetInstance(this).SendBroadcast(intent);
}
}
And finally, Add the meta data in the AndroidManifest.xml under element:
<meta-data android:name="com.google.android.gms.version" android:value="#integer/google_play_services_version" />
If you don't want the IOS and Windows projects in your Wear application, just delete them. Now you can build your Wear application in Xamarin Forms just as you do with your phone application. Happy Coding.
You would not run a Xamarin.Forms application on a wearable device. You would need to create a new Android Wear application in native Xamarin.Android. Wearable Applications use a special theme, special controls, and have special APIs. A good sample to look at is how I did Hanselman.Forms, which is a Xamarin.Forms main application but ties in an Android Wear application as well: https://github.com/jamesmontemagno/Hanselman.Forms
Target: get token which I need to send to the app server
Problem: registered returns true, requests done returns true, but onReq and onRespdid not get called. Here is the code:
public class WeChatActivity extends Activity implements IWXAPIEventHandler {
private static final String APP_ID = ;
private IWXAPI api;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_signin);
api = WXAPIFactory.createWXAPI(this, APP_ID, true);
api.handleIntent(getIntent(), this);
regToWx();
getAuthToken();
}
private void regToWx() {
api.handleIntent(getIntent(), this);
boolean registered = api.registerApp(APP_ID);
L.e(this, "registered: " + registered);
}
#Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
setIntent(intent);
api.handleIntent(intent, this);
}
public void getAuthToken() {
SendAuth.Req req = new SendAuth.Req();
req.scope = "post_timeline";
req.state = "none";
boolean requestDone = api.sendReq(req);
L.e(this, "request done: " + requestDone);
SendAuth.Resp resp = new SendAuth.Resp();
requestDone = api.sendResp(resp);
L.e(this, "request done: " + requestDone);
}
#Override
public void onReq(BaseReq baseReq) {
L.e(this, "scope: " + ((SendAuth.Req) baseReq).scope);
}
#Override
public void onResp(BaseResp baseResp) {
L.e(this, "token: " + ((SendAuth.Resp) baseResp).token);
}
}
Log cat output:
D/MicroMsg.SDK.WXApiImplV10﹕ check signature:308202eb30820254a003020...
D/MicroMsg.SDK.WXApiImplV10﹕ pass
D/MicroMsg.SDK.WXApiImplV10﹕ register app cn.wegazine.wegazine
D/MicroMsg.SDK.MMessage﹕ send mm message, intent=Intent { act=com.tencent.mm.plugin.openapi.Intent.ACTION_HANDLE_APP_REGISTER (has extras) }, perm=com.tencent.mm.permission.MM_MESSAGE
E/WeChatActivity﹕ registered: true
D/MicroMsg.SDK.WXApiImplV10﹕ check signature:308202eb30820...
D/MicroMsg.SDK.WXApiImplV10﹕ pass
D/MicroMsg.SDK.MMessageAct﹕ send mm message, intent=Intent { flg=0x18000000 cmp=com.tencent.mm/.plugin.base.stub.WXEntryActivity (has extras) }
E/WeChatActivity﹕ request done: true
D/MicroMsg.SDK.WXApiImplV10﹕ check signature:308202eb30820...
D/MicroMsg.SDK.WXApiImplV10﹕ pass
D/MicroMsg.SDK.MMessageAct﹕ send mm message, intent=Intent { flg=0x18000000 cmp=com.tencent.mm/.plugin.base.stub.WXEntryActivity (has extras) }
E/WeChatActivity﹕ request done: true
I've face the same problem and solved with two steps.
First check if you've successfully jumped to the wechat app and authorized.
If not, check if you're using the same signing key that you signed to wechat.
(ex. if you signed with the release key and compile with debug key, then wechat app won't open)
Second, by wechat document, the class name should be WXEntryActivity and should be put under a package named wxapi under the package with the name you registered at wechat.
Example in the document: If you register with "net.sourceforge.simcpux", the project structure should look like this
Also, add api.HandleIntent(getIntent(), this) after sendReq and sendResp
Not sure if the classname is neccessary, but I'm sure you can call sendReq in other class and process response with WXEntryActivity
Hope this is helpful.
had the same issue! Edwards answer helped a lot.
WxEntryActivity needs to be in the package with the name you registered at wechat!
Especially when you have multiple build variants (debug, release):
Wechat login - do not receive token
onReq and onResp will be called in WXEntryActivity.java within JAVA reflection
Suppose package name io.github.you
You should create a directory named wxapi,then create a WXEntryActivity.java
You get io.github.you.wxapi.WXEntryActivity.java
In AndroidManifest.xml
<activity
android:name=".wxapi.WXEntryActivity"
android:exported="true"
android:label="#string/title_activity_wxentry"
android:screenOrientation="portrait"
android:theme="#android:style/Theme.NoDisplay" >
In WXEntryActivity.java
public class WXEntryActivity implements IWXAPIEventHandler{
#Override
public void onReq(BaseReq arg0) {
SendAuth.Resp r = (SendAuth.Resp)resp;
String code = r.code;
}
#Override
public void onResp(BaseResp arg0) {
// TODO Auto-generated method stub
}
}
Good Luck