Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 21    Views: 98

Kyle Boyett
Lost but trying
Profile
Posts: 32
Reg: Jan 03, 2015
Waynesville, GA
6,570
01/25/15 06:06 PM (9 years ago)

Socialize implementation problems

Hello everyone, I'm making some head way on my app, after finally getting my maps to do what I want them to do. I'll finish the final touches on them later, as I've got a lot of pinpoints to add and the corresponding descriptions. My thinking is I'd like to get every individual piece to work overall...then do all the detail work. My current issue is with implementing the Socialize SDK. I've got it imported into my project. Libraries are also there, and linked to my app. I've added the socialize.properties file to my assets path, and added my key codes. According to the 'getting started' guide on their website, I have to embed the following code into my app... public class ActionBarSample extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Call Socialize in onCreate Socialize.onCreate(this, savedInstanceState); // Your entity key. May be passed as a Bundle parameter to your activity String entityKey = "http://www.getsocialize.com"; // Create an entity object including a name // The Entity object is Serializable, so you could also store the whole object in the Intent Entity entity = Entity.newInstance(entityKey, "Socialize"); // Wrap your existing view with the action bar. // your_layout refers to the resource ID of your current layout. View actionBarWrapped = ActionBarUtils.showActionBar(this, R.layout.actionbar, entity); // Now set the view for your activity to be the wrapped view. setContentView(actionBarWrapped); } @Override protected void onPause() { super.onPause(); // Call Socialize in onPause Socialize.onPause(this); } @Override protected void onResume() { super.onResume(); // Call Socialize in onResume Socialize.onResume(this); } @Override protected void onStart() { super.onStart(); // Call Socialize in onStart Socialize.onStart(this); } @Override protected void onStop() { super.onStop(); // Call Socialize in onStop Socialize.onStop(this); } @Override protected void onDestroy() { // Call Socialize in onDestroy before the activity is destroyed Socialize.onDestroy(this); super.onDestroy(); } } I'm not exactly sure where this needs to be added, so I tried placing it in a few different files, such as BT_activity_start.java and BT_activiy_host.java. I'm pasting it at the bottom of the existing code. When it builds....it returns with a few errors such as: Socialize cannot be resolved. Entity cannot be resolved. Entity cannot be resolved to a type. actionbar cannot be resolved or is not a field. ActionBarUtils cannot be resolved. View cannot be resolved to a type. I'm not sure if my problem lies with where I pasted the code....or if something else is needed. I've done many searches both here and on socialize forum, and haven't found a definite answer. Would be great if there was a step by step walk through, including what code goes where....I know that every app would be different, but I'm just looking for the basic socialize actionbar to show up on my pages. I'm not worried about custom buttons or colors. At least not at the moment, lol. I've been working on this all day, and at least managed to get my errors down to 11, from 200+. Moving in the right direction, but these last few have me stumped. I have thought of purchasing a few books, but not sure if I need Java, Android, XML, or all of them. Any suggestions on good books? I started off by downloading the socialize demo, and looked through the code...just not sure exactly what I'm looking for. The demo did build and I was able to run it on my attached device. Just can't get to that point with my app because of the above errors. Any help would be appreciated. I did find a link here on Buzztouch to a guide in .pdf, but that link was outdated. Not sure if it would've helped, but who knows. btw, this is for Android, and I'm using Eclipse. Thanks for any help. Kyle
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
01/25/15 09:14 PM (9 years ago)
The challenge you're going to immediately face is that with BT Android v3, we've moved away from 'activities' and put everything into 'fragments'. They're very similar. However, just like Spanish and Italian, 'similar' is never 'the same'. You'll get a lot of errors that pertain to the differences between activities and fragments, and will need to correct those before proceding. It's a chore, but it can be done. It's hard to say 'what to do' because each situation presents it's own set of changes and challenges. If someone else has implemented 'socialize' in Android, then I hope they can chime in with some assistance. otherwise all I can say is, when you post on the forums provide a bit of code, the log file results and what you've tried, and what you're trying to do. More information is usually the key to figuring out what isn't working and why. I can't promise results, but we can promise we'll try to help. Cheers! -- Smug
 
Kyle Boyett
Lost but trying
Profile
Posts: 32
Reg: Jan 03, 2015
Waynesville, GA
6,570
like
01/26/15 02:45 PM (9 years ago)
Thanks for the reply, Smug. When I get around to working on it again, I'll post the results. I was thinking there would be others that have done this successfully....guess we'll just wait and see if any others post. I won't give up, it just may take me awhile, lol. Thanks again
 
Bytewizard
buzztouch Evangelist
Profile
Posts: 32
Reg: Jul 04, 2011
Manila, Philipp...
1,020
like
01/27/15 05:55 PM (9 years ago)
Hi Kyle, I managed to integrate socialize in my projects. and here's what I've done. My buzztouch project configuration : http://gyazo.com/d3f29f25ecf0b2356278b143a32f4ea3 Socialize SDK Configuration http://gyazo.com/f813a98e5e4fc92420a249c69e9ecfcf Then, I've used BT_screen_customHTML plugin to integrate socialize code. Put this at the import portion of BT_screen_customHTML: import com.socialize.ActionBarUtils; import com.socialize.Socialize; import com.socialize.entity.Entity; import com.YourBuzztouchProject.R; Be sure to modify com.YourBuzztouchProject.R to your project preferences. Then, inside onCreateView Method put these code right before the ending curly brace } // I used the ItemID of BT_screen_customHTML plugin as my entitykey String entityKey = this.screenData.getItemId(); // I used the Nickname of BT_screen_customHTML plugin as my entityname String entityName = screenData.getItemNickname(); Entity entity = Entity.newInstance(entityKey, entityName); //return thisScreensView; //Change the return statement to below code: return ActionBarUtils.showActionBar(getActivity(), thisScreensView, entity); then modify these methods to look like the following: @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Socialize.onCreate(this.getActivity(), savedInstanceState); } @Override public void onDestroy() { Socialize.onDestroy(this.getActivity()); super.onDestroy(); } @Override public void onPause() { super.onPause(); Socialize.onPause(this.getActivity()); } @Override public void onResume() { super.onResume(); Socialize.onResume(this.getActivity()); } Hope this help. Good Luck! Diomar
 
Kyle Boyett
Lost but trying
Profile
Posts: 32
Reg: Jan 03, 2015
Waynesville, GA
6,570
like
01/27/15 06:58 PM (9 years ago)
Thank you so much for that post. I checked the links you posted, and that's how mine are referenced as well. I'll give this a try tomorrow after work. I noticed where you said to modify com.YourBuzztouchProject.R to match my app... is there any other lines of code that needed to be modified from what you posted, or can I just copy/paste? Hopefully soon I'll be able to find a good reference book, or online guide to give me a run down on the basics. I'm thinking that'll make some of this a little bit easier, at least if I understand what some of these commands are supposed to do. Thanks again, and we'll see how this goes soon. Kyle
 
Kyle Boyett
Lost but trying
Profile
Posts: 32
Reg: Jan 03, 2015
Waynesville, GA
6,570
like
01/28/15 07:06 PM (9 years ago)
Well.....that didn't go too well, lol. In my BT_screen_customHTML.java file, I do not see any mention of those @override's to modify. I do see them in BT_fragment.java. So, this is where I tried putting these codes in. Hmmmmm..... I tried a few minutes ago and got roughly 8-10 errors..... I deleted all of my changes, and tried again....now, only have 1 error. It's on this line.... return ActionBarUtils.showActionBar(getActivity(), thisScreensView, entity); and it tells me... thisScreensView cannot be resolved to a variable. I'll give it another try tomorrow. Any hints on resolving the above error? Thanks again, Kyle
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
01/28/15 09:01 PM (9 years ago)
A lot of those 'overrides' are to be in the fragmented class. If the fragment doesn't have them, you can add them. Look at it this way; just about all fragments are 'subclassed' from something else, that has those methods. If the local fragment doesn't have those classes, then those methods are handled by the superclass. So something that looks like this: @Override public void onDestroy() { Socialize.onDestroy(this.getActivity()); super.onDestroy(); } Is basically saying "Hey, on Destroy (of this fragment) destroy this instance of socialize as well". Then, the 'super.onDestroy()' is telling it 'now that you're done with the local onDestroy, now head on up to the SuperClass onDestroy and do what it says there as well' So, some fragment/subclasses won't have those methods. But they can be easily added. The same concepts apply to onResume, onStart, etc... Hope this helps. Cheers! -- Smug
 
Bytewizard
buzztouch Evangelist
Profile
Posts: 32
Reg: Jul 04, 2011
Manila, Philipp...
1,020
like
01/29/15 12:20 AM (9 years ago)
Hi kyle, Let us make it easy for you. I just need to know the package name of your buzztouch project(e.g. com.mybuzztouchproject) so that I can modify the BT_screen_customHTML.java then paste it here for you. all you have to do then is to copy and paste to your BT_screen_customHTML.java to replace the existing codes on it. Diomar
 
Niraj
buzztouch Evangelist
Profile
Posts: 2943
Reg: Jul 11, 2012
Cerritos
37,930
like
01/29/15 01:05 AM (9 years ago)
I am amazed at Kyle's persistence, tenacity and perseverance through each technical hurdle. Never once has he considered throwing in the towel. Kyle's upbeat attitude is uplifted by the great BT members on this discussion. Thank you Smug and Bytewizard for showing us the way! :-) Sincerely, -- Niraj
 
Kyle Boyett
Lost but trying
Profile
Posts: 32
Reg: Jan 03, 2015
Waynesville, GA
6,570
like
01/29/15 04:16 AM (9 years ago)
Thanks for the words of wisdom. Especially where Smug said "Look at it this way"...putting it all in common terms. Lol, like I said, I'm no programmer. I think the most programming I've ever done was in Basic with a Commodore 64. Bytewizard....my package name is com.castawaycachers If you'd like, I can zip some of the files up and send them.... whatever works for you. Thanks for that offer. Niraj... Thank you for your comments. I do get frustrated, but usually that just makes me more determined to see it through. I hope to get to the point where I can contribute more here, but until I know what I'm doing, don't want to lead others astray. I've never explained what my overall goal of this app is, so here it goes... One of my 'side jobs' is I'm a Travel Agent. Mostly putting together group cruises, as they're more profitable than a single cabin. The wife and I are also geocachers. (Geocaching.com for more information). We use our GPS to find hidden trinkets throughout the world. The group cruises all consist of like-minded people, hence the name Castaway Cachers. I'm wanting to have this app have: different ways of contacting me (done) all the details of our upcoming group cruise (prices, dates, ports, etc) (page is done, just need to add details) A Google map of each port we'll visit, with pins at each cache location (Done, just need to add the rest of the ports) A page and map for each event that we have, usually the night before we leave and at each port we all get together for group photo and to sign the log. (Somewhat done...just need to add the little details, and more pins) A list of every port we've visited so far (Feb 26 will be our 3rd group cruise) and possibly a page for each port with some basic information on the area. (In progress, page is setup, just needs details) As far as the Socialize portion, I'd like for others to be able to comment on and share the information with anyone else who may be interested in joining us. Not sure if I need to add these socialize commands to other files or not, but I'd like for the actionbar to appear on all screens (I think, lol) (In progress) I tried to add a Chat Room, and didn't like how it turned out. I've got the plugin installed, and used ParaChat, but on running, it would open a pop-up, advertising anti-virus....I didn't like it. Also tried ChatWing...which worked great, but I didn't like the way the 'guest' login operated. Looked into QuickBlox, but couldn't figure out how to implement, may try again later. (May return to this later, but hope Socialize will have enough functionality.) Whew.... Gotta head to my real job, so I'll check back this evening. Thanks again to everyone here, I'm sure I'll get this going. Kyle
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
01/29/15 05:59 AM (9 years ago)
My wife and I used to love Geocaching in Japan. It was our way of finding new places on the weekends. And even though it was planted 4 years ago, my cache still seems to survive. :) http://www.geocaching.com/geocache/GC27RMX_the-village-well Cheers! -- Smug
 
Kyle Boyett
Lost but trying
Profile
Posts: 32
Reg: Jan 03, 2015
Waynesville, GA
6,570
like
01/29/15 03:31 PM (9 years ago)
Cool beans, Smug. We enjoy it, and it also allows me to cater to a target market with the cruises. Along with a few other side businesses I operate. Now, back to giving this app another try. Kyle
 
Kyle Boyett
Lost but trying
Profile
Posts: 32
Reg: Jan 03, 2015
Waynesville, GA
6,570
like
01/29/15 05:52 PM (9 years ago)
Hello again, Seems that somewhere along the way with messing with Socialize, I must have reverted to a previous build. I lost my two line text button, and maps weren't working..... always something. Got those issues resolved, and got back into my socialize problem. I removed all my added code from BT_fragment.java, and added them (again) to BT_screen_customHTML.java... Still had same error as above. Removed them again, and started line by line adding the posted codes, checking for red X's as I went. Took some time to find the sweet spot for the entity and return lines...but I did find it. I did it!!!! I've successfully got Socialize implemented in my app. Still have a few final touches to go, such as setting up the Facebook and Twitter connections. Thank you all for all of the support. I'm sure I'll be posting again soon, with another issue, lol. Kyle
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
01/29/15 07:02 PM (9 years ago)
Sweet! I guess that tortise/hare story is true! Slow and steady always wins the race! Cheers! -- Smug
 
Niraj
buzztouch Evangelist
Profile
Posts: 2943
Reg: Jul 11, 2012
Cerritos
37,930
like
01/29/15 10:41 PM (9 years ago)
Yeehaw!!! :-) -- Niraj
 
Bytewizard
buzztouch Evangelist
Profile
Posts: 32
Reg: Jul 04, 2011
Manila, Philipp...
1,020
like
01/30/15 08:12 AM (9 years ago)
Hi Kyle, Here's the full source code for your BT_screencustomHTML.java in case you still need it and might as well serve as a reference to other Buzztouch users who needs to implement socialize using BT_screencustomHTML. /* * Copyright 2011, David Book, buzztouch.com * * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice which includes the * name(s) of the copyright holders. It must also retain this list of conditions and the * following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. * * Neither the name of David Book, or buzztouch.com nor the names of its contributors * may be used to endorse or promote products derived from this software without specific * prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. */ package com.castawaycachers ; import java.io.File; import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.webkit.WebView; import android.webkit.WebViewClient; import com.socialize.ActionBarUtils; import com.socialize.Socialize; import com.castawaycachers.R; import com.socialize.entity.Entity; public class BT_screen_customHTML extends BT_fragment{ public DownloadScreenDataWorker downloadScreenDataWorker; public WebView webView = null; public String localFileName = ""; public String saveAsFileName = ""; public String dataURL = ""; public String currentURL = ""; public String originalURL = ""; public String showBrowserBarBack = ""; public String showBrowserBarLaunchInNativeApp = ""; public String showBrowserBarEmailDocument = ""; public String showBrowserBarRefresh = ""; public String forceRefresh = ""; //onCreateView... @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){ /* Note: fragmentName property is already setup in the parent class (BT_fragment). This allows us to add the name of this class file to the LogCat console using the BT_debugger. */ //show life-cycle event in LogCat console... BT_debugger.showIt(fragmentName + ":onCreateView JSON itemId: \"" + screenData.getItemId() + "\" itemType: \"" + screenData.getItemType() + "\" itemNickname: \"" + screenData.getItemNickname() + "\""); //inflate the layout file for this screen... View thisScreensView = inflater.inflate(R.layout.bt_screen_customhtml, container, false); //Socialize //SocializeConfig config = ConfigUtils.getConfig(this.getActivity()); //return ActionBarUtils.showActionBar(getActivity(), view, entity); //reference to the webview in the layout file. webView = (WebView) thisScreensView.findViewById(R.id.webView); webView.setBackgroundColor(0); webView.setInitialScale(0); webView.getSettings().setJavaScriptEnabled(true); webView.getSettings().setSupportZoom(true); webView.getSettings().setBuiltInZoomControls(true); webView.getSettings().setPluginsEnabled(true); webView.setWebViewClient(new WebViewClient(){ @Override public boolean shouldOverrideUrlLoading(WebView view, String url){ //remember the URL... currentURL = url; //load the URL in the app's built-in browser if it's in our list of types to load... if(canLoadDocumentInWebView(url)){ //load url in built-in browser... showProgress(null, null); return false; }else{ //ask user what app to open this in if the method returned NO... try{ Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); startActivity(Intent.createChooser(i, getString(R.string.openWithWhatApp))); }catch(Exception e){ BT_debugger.showIt(fragmentName + ": Error launching native app for url: " + url); showAlert(getString(R.string.noNativeAppTitle), getString(R.string.noNativeAppDescription)); } //do not try to load the URL.. return true; } } @Override public void onPageFinished(WebView view, String url){ hideProgress(); BT_debugger.showIt(fragmentName + ":onPageFinished finished Loading: " + url); } @Override public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { hideProgress(); showAlert(getString(R.string.errorTitle), getString(R.string.errorLoadingScreen)); BT_debugger.showIt(fragmentName = ":onReceivedError ERROR loading url: " + failingUrl + " Description: " + description); } }); //fill JSON properties... dataURL = BT_strings.getJsonPropertyValue(this.screenData.getJsonObject(), "dataURL", ""); localFileName = BT_strings.getJsonPropertyValue(this.screenData.getJsonObject(), "localFileName", ""); forceRefresh = BT_strings.getJsonPropertyValue(this.screenData.getJsonObject(), "forceRefresh", "0"); currentURL = dataURL; originalURL = dataURL; //if we have NO localFileName and no dataURL, use the sample file for this plugin... if(localFileName.length() < 1 && dataURL.length() < 1){ localFileName = "bt_screen_customhtml_sample.html"; } //setup the saveAsFileName if(localFileName.length() > 1){ //use the file name in the JSON data... saveAsFileName = localFileName; //copy the file from the /assets/BT_Docs folder so we can use it later... BT_fileManager.copyAssetToCache("BT_Docs", saveAsFileName); }else{ //create a file name... saveAsFileName = this.screenData.getItemId() + "_screenData.html"; } //remove file if we are force-refreshing... if(forceRefresh.equalsIgnoreCase("1")){ BT_fileManager.deleteFile(saveAsFileName); } //button options for hardware menu key... showBrowserBarBack = BT_strings.getJsonPropertyValue(this.screenData.getJsonObject(), "showBrowserBarBack", "0"); showBrowserBarLaunchInNativeApp = BT_strings.getJsonPropertyValue(this.screenData.getJsonObject(), "showBrowserBarLaunchInNativeApp", "0"); showBrowserBarEmailDocument = BT_strings.getJsonPropertyValue(this.screenData.getJsonObject(), "showBrowserBarEmailDocument", "0"); showBrowserBarRefresh = BT_strings.getJsonPropertyValue(this.screenData.getJsonObject(), "showBrowserBarRefresh", "0"); //prevent user interaction? String preventUserInteraction = BT_strings.getJsonPropertyValue(this.screenData.getJsonObject(), "preventUserInteraction", "0"); if(preventUserInteraction.equalsIgnoreCase("1")){ //can't seem to get Android to "prevent user interaction"...??? } //hide scroll bars.. String hideVerticalScrollBar = BT_strings.getJsonPropertyValue(this.screenData.getJsonObject(), "hideVerticalScrollBar", "0"); if(hideVerticalScrollBar.equalsIgnoreCase("1")){ webView.setVerticalScrollBarEnabled(false); } String hideHorizontalScrollBar = BT_strings.getJsonPropertyValue(this.screenData.getJsonObject(), "hideHorizontalScrollBar", "0"); if(hideHorizontalScrollBar.equalsIgnoreCase("1")){ webView.setHorizontalScrollBarEnabled(false); } String preventAllScrolling = BT_strings.getJsonPropertyValue(this.screenData.getJsonObject(), "preventAllScrolling", "0"); if(preventAllScrolling.equalsIgnoreCase("1")){ webView.setVerticalScrollBarEnabled(false); webView.setHorizontalScrollBarEnabled(false); } //figure out what to load... if(dataURL.length() > 1){ //if we have a cached version, load that... if(BT_fileManager.doesCachedFileExist(saveAsFileName) && !forceRefresh.equalsIgnoreCase("1")){ //load from cache BT_debugger.showIt(fragmentName + ": loading from cache: " + saveAsFileName); String theData = BT_fileManager.readTextFileFromCache(saveAsFileName); this.showProgress(null, null); this.loadDataString(theData); }else{ //load from URL BT_debugger.showIt(fragmentName + ": loading from URL: " + dataURL); this.downloadAndSaveFile(dataURL, saveAsFileName); } }else{ //HTML doc must be in /assets/BT_Docs folder... if(!BT_fileManager.doesProjectAssetExist("BT_Docs", saveAsFileName)){ BT_debugger.showIt(fragmentName + ": ERROR. HTML file \"" + saveAsFileName + "\" does not exist in BT_Docs folder and not URL found? Not loading."); showAlert(getString(R.string.errorTitle), getString(R.string.errorLoadingScreen)); }else{ //load from BT_Docs folder... BT_debugger.showIt(fragmentName + ": loading from BT_Docs: " + saveAsFileName); this.showProgress(null, null); webView.loadUrl("file:///android_asset/BT_Docs/" + saveAsFileName); } } String entityKey = this.screenData.getItemId(); //saveAsFileName; //BT_strings.getJsonPropertyValue(this.screenData.getJsonObject(), "dataURL", ""); //config.getProperty("entity.key"); String entityName = screenData.getItemNickname(); //config.getProperty("entity.name"); Entity entity = Entity.newInstance(entityKey, entityName); //return... //return thisScreensView; return ActionBarUtils.showActionBar(getActivity(), thisScreensView, entity); }//onCreateView... //Socialize for EntityLoader // public static BT_screen_customHTML newInstance(String entityKeyString) { // BT_screen_customHTML customHTML = new BT_screen_customHTML(); // Bundle args = new Bundle(); // args.putString("entityKey", entityKeyString); // customHTML.setArguments(args); // return customHTML; // } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Socialize.onCreate(this.getActivity(), savedInstanceState); } @Override public void onDestroy() { Socialize.onDestroy(this.getActivity()); super.onDestroy(); } @Override public void onPause() { super.onPause(); Socialize.onPause(this.getActivity()); } @Override public void onResume() { super.onResume(); Socialize.onResume(this.getActivity()); } //load URL in webView... public void loadUrl(String theUrl){ BT_debugger.showIt(fragmentName + ": loadUrl"); try{ webView.loadUrl(theUrl); }catch(Exception e){ BT_debugger.showIt(fragmentName + ":loadUrl Exception: " + e.toString()); } } //load html string... public void loadDataString(String theString){ BT_debugger.showIt(fragmentName + ": loadDataString"); webView.loadDataWithBaseURL(null, theString, "text/html", "utf-8", "about:blank"); hideProgress(); } //back button... public void handleBackButton(){ BT_debugger.showIt(fragmentName + ":handleBackButton"); if(webView.canGoBack()){ webView.goBack(); }else{ BT_debugger.showIt(fragmentName + ":handleBackButton cannot go back?"); } } //refresh button... public void handleRefreshButton(){ BT_debugger.showIt(fragmentName + ":handleRefreshButton"); if(currentURL.length() > 1){ //remove cached version... BT_fileManager.deleteFile(saveAsFileName); //re-load... loadUrl(currentURL); }else{ BT_debugger.showIt(fragmentName + ":handleRefreshButton cannot refresh?"); } } //launch in native app button... public void handleLaunchInNativeAppButton(){ BT_debugger.showIt(fragmentName + ":handleLaunchInNativeAppButton"); if(currentURL.length() > 1 && originalURL.length() > 1){ launchInNativeApp(); }else{ showAlert(castawaycachers_appDelegate.getApplication().getString(R.string.noNativeAppTitle), getString(R.string.noNativeAppDescription)); BT_debugger.showIt(fragmentName + ":handleLaunchInNativeAppButton NO url?"); } } //launch in native app public void launchInNativeApp(){ if(this.dataURL.length() > 1){ BT_debugger.showIt(fragmentName + ":handleLaunchInNativeAppButton URL: " + this.dataURL); Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(this.dataURL)); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); }else{ showAlert(getString(R.string.errorTitle), getString(R.string.cannotOpenDocumentInNativeApp)); BT_debugger.showIt(fragmentName + ":handleLaunchInNativeAppButton ERROR, no URL. Cannot load local files in native browser."); } } //handleEmailDocumentButton public void handleEmailDocumentButton(){ //must have already downloaded the document if(castawaycachers_appDelegate.rootApp.getRootDevice().canSendEmail() && BT_fileManager.doesCachedFileExist(saveAsFileName)){ try{ //copy file from cache to SDCard so emailer can access it (can't email from internal files directory)... BT_fileManager.copyFileFromCacheToSDCard(saveAsFileName); //copy from assets to internal cache... File file = new File(castawaycachers_appDelegate.getApplication().getExternalCacheDir(), saveAsFileName); String savedToPath = file.getAbsolutePath(); //make sure file exists... if(file.exists()){ //send from path...THIS IS REQUIRED OR GMAIL CLIENT WILL NOT INCLUDE ATTACHMENT String sendFromPath = "file:///sdcard/Android/data/com.castawaycachers/cache/" + saveAsFileName; //send a link to a url OR a file, not both... if(currentURL.length() > 1){ //tell Android launch the native email application... Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType("plain/text"); emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, getString(R.string.sharingWithYou)); emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, currentURL); //chooser will prompt user if they have more than one email client.. startActivity(Intent.createChooser(emailIntent, getString(R.string.openWithWhatApp))); }else{ //tell Android launch the native email application... Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType("text/plain"); emailIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, getString(R.string.sharingWithYou)); emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "\n\n" + getString(R.string.attachedFile)); emailIntent.putExtra(android.content.Intent.EXTRA_STREAM, Uri.parse(sendFromPath)); //open users email app... startActivity(emailIntent); }//dataURL... }else{ BT_debugger.showIt(fragmentName + ":handleEmailDocumentButton Cannot email document, file does not exist: " + savedToPath); } }catch(Exception e){ showAlert(getString(R.string.errorTitle), getString(R.string.cannotEmailDocument)); BT_debugger.showIt(fragmentName + ":handleEmailDocumentButton EXCEPTION " + e.toString()); } }else{ showAlert(castawaycachers_appDelegate.getApplication().getString(R.string.noNativeAppTitle), getString(R.string.noNativeAppDescription)); BT_debugger.showIt(fragmentName + ":handleEmailDocumentButton Cannot email document, no URL provided"); } } //download and save file.... public void downloadAndSaveFile(String dataURL, String saveAsFileName){ //show progress showProgress(null, null); //trigger the download... downloadScreenDataWorker = new DownloadScreenDataWorker(); downloadScreenDataWorker.setDownloadURL(dataURL); downloadScreenDataWorker.setSaveAsFileName(saveAsFileName); downloadScreenDataWorker.setThreadRunning(true); downloadScreenDataWorker.start(); } /////////////////////////////////////////////////////////////////// //DownloadScreenDataThread and Handler Handler downloadScreenDataHandler = new Handler(){ @Override public void handleMessage(Message msg){ hideProgress(); //read text file, load in webView... //if we have a cached version, load that... if(BT_fileManager.doesCachedFileExist(saveAsFileName)){ //load from cache BT_debugger.showIt(fragmentName + ": loading from cache: " + saveAsFileName); String theData = BT_fileManager.readTextFileFromCache(saveAsFileName); loadDataString(theData); }else{ //error. We should have downloaded then cached... showAlert(getString(R.string.errorTitle), getString(R.string.fileNotDownloadedYet)); BT_debugger.showIt(fragmentName + ": ERROR loading from cache after download: " + dataURL); } } }; public class DownloadScreenDataWorker extends Thread{ boolean threadRunning = false; String downloadURL = ""; String saveAsFileName = ""; void setThreadRunning(boolean bolRunning){ threadRunning = bolRunning; } void setDownloadURL(String theURL){ downloadURL = theURL; } void setSaveAsFileName(String theFileName){ saveAsFileName = theFileName; } @Override public void run(){ //downloader will fetch and save data..Set this screen data as "current" to be sure the screenId //in the URL gets merged properly. Several screens could be loading at the same time... String useURL = BT_strings.mergeBTVariablesInString(dataURL); BT_debugger.showIt(fragmentName + ":downloading HTML (plain / text) data from " + useURL + " Saving As: " + saveAsFileName); BT_downloader objDownloader = new BT_downloader(useURL); objDownloader.setSaveAsFileName(saveAsFileName); @SuppressWarnings("unused") String result = objDownloader.downloadTextData(); //send message to handler.. this.setThreadRunning(false); downloadScreenDataHandler.sendMessage(downloadScreenDataHandler.obtainMessage()); } } //END DownloadScreenDataThread and Handler /////////////////////////////////////////////////////////////////// //onCreateOptionsMenu... @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { BT_debugger.showIt(fragmentName + ":onCreateOptionsMenu JSON itemId: \"" + screenItemId + "\""); /* Screens that extend BT_fragment should implement their own onCreateOptionsMenu() method to add action bar items specific to that screen. They should call super.onCreateOptionsMenu() AFTER adding customized items for that screen. */ //for individual menu items... MenuItem menuItem = null; //back... if(showBrowserBarBack.equalsIgnoreCase("1")){ menuItem = menu.add(Menu.NONE, 1, 0, getString(R.string.back)); menuItem.setIcon(BT_fileManager.getDrawableByName("bt_prev.png")); menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); } //launch in native app... if(showBrowserBarLaunchInNativeApp.equalsIgnoreCase("1")){ menuItem = menu.add(Menu.NONE, 2, 0, getString(R.string.browserOpenInNativeApp)); menuItem.setIcon(BT_fileManager.getDrawableByName("bt_action.png")); menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); } //email document... if(showBrowserBarEmailDocument.equalsIgnoreCase("1")){ menuItem = menu.add(Menu.NONE, 3, 0, getString(R.string.browserEmailDocument)); menuItem.setIcon(BT_fileManager.getDrawableByName("bt_compose.png")); menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); } //refresh page... if(showBrowserBarRefresh.equalsIgnoreCase("1") && dataURL.length() > 1){ menuItem = menu.add(Menu.NONE, 4, 0, getString(R.string.browserRefresh)); menuItem.setIcon(BT_fileManager.getDrawableByName("bt_refresh.png")); menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); } //call super... super.onCreateOptionsMenu(menu, inflater); } @Override public boolean onOptionsItemSelected(MenuItem item) { BT_debugger.showIt(fragmentName + ":onOptionsItemSelected JSON itemId: \"" + screenItemId + "\" Selected Item's Id: " + item.getItemId()); /* Handling menu item taps: Each screen that extends BT_fragment should implement the onOptionsItemSelected() method to handle taps for items specific to that screen. Each menu item added for a screen should use an itemId greater than -1. */ //handle item selection. switch (item.getItemId()){ case 1: //back... handleBackButton(); return true; case 2: //native app... handleLaunchInNativeAppButton(); return true; case 3: //email document... handleEmailDocumentButton(); return true; case 4: //refresh browser... handleRefreshButton(); return true; } //return... return super.onOptionsItemSelected(item); } }
 
Kyle Boyett
Lost but trying
Profile
Posts: 32
Reg: Jan 03, 2015
Waynesville, GA
6,570
like
01/30/15 04:22 PM (9 years ago)
Thank you for posting that. I got mine running earlier, but like you said, I'm sure it will help someone else going through the same issues. Just a reminder to change the package name if someone does need this code. Now, to figure out how to have the content that's displayed on the screen to be shared, and not just the title.... always something, right? lol Thanks again, Kyle
 
Kyle Boyett
Lost but trying
Profile
Posts: 32
Reg: Jan 03, 2015
Waynesville, GA
6,570
like
01/30/15 05:54 PM (9 years ago)
Bytewizard....since you've used Socialize, I'm hoping you can also answer this question... of course, anyone else can answer too, lol. Clicking 'share' in the actionbar, does allow me to share to Facebook, or email/text.... but, it only includes the title of the entity. Is there a way to 'share' the content of the page? For example... If I have a screen with the prices and details of our next cruise, and someone using the app wanted to share this info with someone (not using the app), can the screen info be sent? These screens are currently _customHTML. I was thinking maybe a PDF could be used? I do have a few web domains that I could host the files on. If using another type of screen would allow me to share the actual text, I'd have to reconfigure my app. But, this type of sharing is what I thought I would be able to do. If you know of a way of doing this, I'd appreciate the help. Thanks, Kyle
 
Bytewizard
buzztouch Evangelist
Profile
Posts: 32
Reg: Jul 04, 2011
Manila, Philipp...
1,020
like
01/31/15 11:56 AM (9 years ago)
Hi Kyle, I do understand what you want to do. Though, I haven't tried it yet but I think this is what you are looking for. http://socialize.github.io/socialize-sdk-android/entities.html?v=v3.1.3#entity-meta-data Cheers, Diomar
 
Kyle Boyett
Lost but trying
Profile
Posts: 32
Reg: Jan 03, 2015
Waynesville, GA
6,570
like
01/31/15 04:40 PM (9 years ago)
I looked at that link briefly. Not quite understanding it, though. I did try using a _customurl instead of _customHTML....same result. If I can figure out how to 'share' the actual url of the screen, that would be ok, as those files are all hosted on my site. Still doing my research, and hope to find a way of sharing the info with those that don't have the app. I realize the purpose of that is to encourage people to download the app, but some of my clients don't use Facebook, or even have a smartphone. I'll take a look at the socialize site and see if I can include the url... Thanks, Kyle
 
Kyle Boyett
Lost but trying
Profile
Posts: 32
Reg: Jan 03, 2015
Waynesville, GA
6,570
like
02/23/15 05:58 PM (9 years ago)
Hello everyone, Just an update on my app .... still in progress, lol. I'm still fighting with my code to get it to do what I want. I believe the answer lies in the link Byte posted above, but I'm not sure in which file this would need to be added. I'm thinking it would be the same file that the Socialize bar is utilized, such as _customurl and _customhtml. I'm also not sure which portions of code from that link above should be added. I've got a thread on their support site http://support.getsocialize.com/socialize/topics/attempting-to-implement-socialize-with-buzztouch-v3-code-for-android-using-eclipse but, haven't gotten very far with that, as the one person who is answering, is speaking over my head as far as coding goes. We're leaving for vacation on Wednesday morning, and won't be back till March 7, so I won't be around for awhile. I'm loading my app on my phone and taking it with me to show it off and get some friends to critique it. I'll get back into working on my app after we return, but in the mean time, if anyone feels like taking a look at the support site I posted, and can make some sense of it, I'd appreciate a dumbed down version, lol. Thanks again for all the help. Kyle
 
Niraj
buzztouch Evangelist
Profile
Posts: 2943
Reg: Jul 11, 2012
Cerritos
37,930
like
07/29/15 07:17 AM (8 years ago)
How did this work out for you?
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.