Preface
The new version number SHARESDK share and SMS verification, according to the official website of the document, you need to add a <Activity></Activity> tag, and share and short-term verification of this tag content is the same. Will conflict.
Workaround: Share with the old version number, SMS verification with the new version number.
There will be a workaround later.
Share
Import project See initial Knowledge sharesdk--embedding and landing
<span style= "FONT-SIZE:24PX;" >onekeyshare OKs = new Onekeyshare ();//All SSO is for Sina Weibo doks.disablessowhenauthorize (); Oks.setsilent (true); </ Span>
Assumptionsif no sharing platform is specified, all default platforms will jump out.
Oks.setplatform (PlatformName);
Something that needs to be noted. The gaze has been very specific.
This method is not called when sharing notification icon and text 2.5.9 later version number//oks.setnotification (R.drawable.ic_launcher, getString (r.string.app_ name)); Title, Evernote, mailbox, information, Renren and QQ space use Oks.settitle (getString (R.string.share));//Titleurl is the title of the network link, only in Renren and QQ space use Oks.settitleurl ("http://sharesdk.cn"); Text is to share, all platforms need this field//have the word limit oks.settext ("I am sharing text");//ImagePath is the local path to the picture, the platform outside of Linked-in supports this parameter (assuming that there is no local, The following statement will not run)//oks.setimagepath ("/sdcard/test.jpg");//Make sure that the sdcard is present in this picture <span style= "White-space:pre" ></ Span>//oks.setimageurl ("=");//network path QQ Space sometimes sharing is not successful (permissions issues)//URL only in (including friends and Friends Circle) use Oks.seturl ("http://sharesdk.cn "); Comment is my comment on this share. Use oks.setcomment only in Renren and QQ space ("I am a test review text"); Site is the name to share this content, only in the QQ space use Oks.setsite (getString (r.string.app_name)); SiteURL is the site address to share this content, only in the QQ space use Oks.setsiteurl ("http://sharesdk.cn"); Set latitude and longitude (can be obtained according to location)//oks.setlatitude (latitude); Oks.setlongitude (longitude); Start sharing GUI (graphical user interface) Oks.show (this);</span>
SMS Verification SMS Verification and login sharing application key and secret are not the same place. I made this mistake, the result is verified when the prompt Appkey is invalid or disabled.
。
Official website Download SDK
Copy the Smssdk file from the SMS directory into project and import it as a library.
Join permissions:
<uses-permission android:name= "Android.permission.READ_CONTACTS"/> <uses-permission android:name= " Android.permission.READ_PHONE_STATE "/> <uses-permission android:name=" android.permission.WRITE_ External_storage "/> <uses-permission android:name=" Android.permission.ACCESS_NETWORK_STATE "/> <uses-permission android:name= "Android.permission.ACCESS_WIFI_STATE"/> <uses-permission android: Name= "Android.permission.INTERNET"/> <uses-permission android:name= "Android.permission.RECEIVE_SMS"/ > <uses-permission android:name= "Android.permission.GET_TASKS"/> <uses-permission android: Name= "Android.permission.ACCESS_FINE_LOCATION"/>
Add code calls:
SMSSDK.INITSDK (This, App_key, App_secret); Registerpage page = new Registerpage ();p age.setregistercallback (new EventHandler () {@Overridepublic void afterevent ( int event, int result, Object data) {if (result = = Smssdk. Result_complete) {hashmap<string,object> Phonemap = (hashmap<string, object>) data; String country = (string) phonemap.get ("Country"); String phone = (string) phonemap.get ("Phone"); Submit user information, this method is acquired after the phone. The action you want to take. RegisterUser (country, phone); System.out.println (Country+phone);}}); Page.show (this);
Define your own SMS verification interface
It's all official documents.
The private EventHandler eh, declared as global. In order to OnDestroy () in the activity, the EventHandler logoff verification smssdk.unregistereventhandler (EH);
Eh=new EventHandler () { @Override public void afterevent (int event, int result, Object data) { if (result = = SM Ssdk. Result_complete) { //callback Complete if (event = = Smssdk. Event_submit_verification_code) { //Submit Verification code successfully SYSTEM.OUT.PRINTLN ("success. "); } else if (event = = Smssdk. Event_get_verification_code) { //Get Verification Code Success System.out.println ("Get Verification Code succeeded"); } else if (event ==smssdk. event_get_supported_countries) { //Returns a list of countries that support sending verification codes } }else{ ((throwable) data). Printstacktrace ();}} ; Smssdk.registereventhandler (EH); Note SMS Callback
to add a listener event to a button:
Get SMS Verification Btn_num.setonclicklistener (new Onclicklistener () {@Overridepublic void OnClick (View arg0) {if (! Textutils.isempty (Et_num.gettext (). ToString ())) {Smssdk.getverificationcode ("" Et_num.gettext (). ToString ());}}); /submit the verification code in the SMS to Serverbtn_code.setonclicklistener (new Onclicklistener () {@Overridepublic void OnClick (View arg0) { Smssdk.submitverificationcode ("n", Et_num.gettext (). ToString (), Et_code.gettext (). ToString ());});
Document address: No GUI interface call
SHARESDK new version number SMS verification and sharing conflict resolutiondue to the new version number SHARESDK in the share and verify. Mainfest in the name "Com.mob.tools.MobUIShell" in a project will conflict.
Share:the mainfest file node
<activity android:name= "Com.mob.tools.MobUIShell" android:configchanges= "keyboardhidden|orientation |screensize " android:screenorientation=" Portrait " android:theme=" @android: style/ Theme.Translucent.NoTitleBar " android:windowsoftinputmode=" Statehidden|adjustresize ">
instead:
<activity android:name= "Cn.sharesdk.framework.ShareSDKUIShell" android:configchanges= " Keyboardhidden|orientation|screensize " android:screenorientation=" Portrait " android:theme=" @android: Style/theme.translucent.notitlebar " android:windowsoftinputmode=" Statehidden|adjustresize ">
will be share in the Libs
The corresponding 2.6.0 is replaced by theSMS verification is not changed.
[Android] sharesdk--content sharing and SMS verification