Browse Source

UU运动分享个好友发消息的没问题了。

FANGLH 8 years ago
parent
commit
3dfc92c82e

+ 1 - 1
app_modular/appme/src/main/java/com/uas/appme/pedometer/utils/StepUtils.java

@@ -226,7 +226,7 @@ public class StepUtils {
 
 
     /**
-     * 分享UU运动的发消息方法
+     * 分享UU运动的发消息方法,只要在调用该方法的上下文中bind mService就可以了
      * @param ownerId
      * @param ownerName
      * @param objectId

+ 22 - 3
app_modular/appme/src/main/java/com/uas/appme/pedometer/view/PersonalPageActivity.java

@@ -1,7 +1,10 @@
 package com.uas.appme.pedometer.view;
 
+import android.content.ComponentName;
 import android.content.Intent;
+import android.content.ServiceConnection;
 import android.os.Bundle;
+import android.os.IBinder;
 import android.util.Log;
 import android.view.Gravity;
 import android.view.LayoutInflater;
@@ -65,7 +68,7 @@ public class PersonalPageActivity extends BaseActivity implements View.OnClickLi
     private PersonalStepBean mPersonalStepBean;
     private Button mbtnAttention;
     private LineChartView lineChart;
-    private String shareStepStr = "分享了UU运动内容给你";
+    private String shareStepStr = "我正在使用UU运动计步功能,你也一起来吧";
     private ImageView share_bitmap_im;
     private LinearLayout line_chart_ll;
     private int my_rank;
@@ -75,10 +78,16 @@ public class PersonalPageActivity extends BaseActivity implements View.OnClickLi
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.personal_page_activity);
+        bindService(CoreService.getIntent(), mConnection, BIND_AUTO_CREATE);
         initView();
     }
 
 
+    @Override
+    protected void onDestroy() {
+        super.onDestroy();
+        unbindService(mConnection);
+    }
     private void initView() {
         Intent intent = getIntent();
         title = intent.getStringExtra("title");
@@ -321,7 +330,7 @@ public class PersonalPageActivity extends BaseActivity implements View.OnClickLi
             startActivity(intent);
             closePopupWindow();
         }else if (v.getId() == R.id.not_rankingwith_tv){
-            ToastMessage("not_rankingwith_tv");
+//            ToastMessage("not_rankingwith_tv");
             closePopupWindow();
         }
     }
@@ -334,10 +343,20 @@ public class PersonalPageActivity extends BaseActivity implements View.OnClickLi
             String ownerId = MyApplication.getInstance().mLoginUser.getUserId();
             String ownerName = CommonUtil.getSharedPreferences(MyApplication.getInstance(), "erp_emname");
             String objectId = model.getImid();
-            mService = new CoreService();
             StepUtils.sendMessage(mService,ownerId,ownerName,objectId,shareStepStr);
             LogUtil.d("0x01",JSON.toJSONString(model));
         }
     }
+    private ServiceConnection mConnection = new ServiceConnection() {
+        @Override
+        public void onServiceDisconnected(ComponentName name) {
+            mService = null;
+        }
 
+        @Override
+        public void onServiceConnected(ComponentName name, IBinder service) {
+            mService = ((CoreService.CoreServiceBinder) service).getService();
+
+        }
+    };
 }