首先在AndroidManifest.xml中加上一系列权限
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_LOGS" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.GET_TASKS" />
<uses-permission android:name="android.permission.SET_DEBUG_APP" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS" />
导入第三方库 删除本项目libs包下的v4包
然后给 application 添加 name 找到自定义的application类
添加 key值
<meta-data
android:name="UMENG_APPKEY"
android:value="ZIpppsYuaMyfvdS705RuySvd" >
</meta-data>
然后 微信
<activity
android:name="com.umeng.soexample.wxapi.WXEntryActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:exported="true"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Translucent.NoTitleBar" />
微信回调
<activity
android:name="com.example.umeng.WXEntryActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:exported="true"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Translucent.NoTitleBar" />
<!-- qq -->
<activity
android:name="com.tencent.tauth.AuthActivity"
android:launchMode="singleTask"
android:noHistory="true" >
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="tencent1105184367" />
</intent-filter>
</activity>
<activity
android:name="com.tencent.connect.common.AssistActivity"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Translucent.NoTitleBar" />
<!-- 微博 -->
<activity
android:name=".WBShareActivity"
android:configChanges="keyboardHidden|orientation"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="com.sina.weibo.sdk.action.ACTION_SDK_REQ_ACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="com.sina.weibo.sdk.component.WeiboSdkBrowser"
android:configChanges="keyboardHidden|orientation"
android:exported="false"
android:windowSoftInputMode="adjustResize" >
</activity>
<service
android:name="com.sina.weibo.sdk.net.DownloadService"
android:exported="false" >
</service>
创建application类 继承Application 记得修改ID与key
public class App extends Application {
@Override
public void onCreate() {
// TODO Auto-generated method stub
super.onCreate();
// 微信 appid appsecret
PlatformConfig.setWeixin("wx967daebe835fbeac",
"5bb696d9ccd75a38c8a0bfe0675559b3");
// 新浪微博 appkey appsecret
PlatformConfig.setSinaWeibo("3921700954",
"04b48b094faeb16683c32669824ebdad");
// QQ和Qzone appid appkey
PlatformConfig.setQQZone("1105184367", "ZCN06OCGTUy0ePpq");
}
}
如果有微信创建WXEntryActivity类 继承WXCallbackActivity就行了 啥也不用写