Skip to main content

Posts

PreviewImage not showing up in widget list on android?

Few things to keep in mind when you're trying to set a preview image for your android widget: Set the android:icon attribute on the corresponding receiver in your AndroidManifest.xml to the same drawable as the one mentioned in the android:previewImag e attribute of your widget.xml file. Don't use too big (when it comes to resolution) preview images, as android anyway will scale them up. As a rule of thumb I've noticed that I have to scale down preview images (from their original size after doing screenshot in ddms) to 75% for small widgets (taking 1 row) and approx 50% for full screen widgets. Otherwise you'll get error saying that the widget dragging couldn't be initialized. Most widgets anyway don't use preview, so don't worry about it too much :)

Easy swipe gesture handling on android

Recently I wanted to implement swipe functionality for activity in my android app but couldn't find a nice and simple example that would explain what do you really need to do. There are multiple sites that are bloated with code, but somehow I couldn't believe that to implement such a simple (and kinda basic if you think about it) functionality you need to write tens of lines of code. So if you're like me, looking for a simple and elegant solution for swipe gesture handling, here it is... First some theory - to implement swipe you will need to: 1. Create a GestureDetector 2. Create an OnGestureListener by extending GestureDetector.SimpleOnGestureListener 3. Implement onFling method in listener created in step 2 4. Handle the onTouchEvent in your activity Now let's jump to the code: import android.app.Activity; import android.os.Bundle; import android.view.GestureDetector; import android.view.MotionEvent; public class MySwipeSupportedActivity extends ...

Free online learning

Recently I saw a great TED talk about high quality free online courses offered by some of the most famous universities around the world (like MIT, Stanford) , "Daphne Koller: What we're learning from online education", available at   http://www.ted.com/talks/daphne_koller_what_we_re_learning_from_online_education.html The whole talk is really great, with some tips how to improve the effectiveness of online trainings. I did also some googling and found following websites that offer free learning courses (or index them) from various disciplines. Really worth checking and signing up: https://www.coursera.org/  - site mentioned by Daphne Koller. 124 courses offered. https://www.edx.org/  - MIT, Berkley, Harvard - some of the courses start in September and beginning of October http://www.schneider-electric.com.au/sites/australia/en/company/data-center-free-online-training-courses.page  - Data Center University offers a lot of computer-related courses http://ocw....

Eclipse + EGit - "The authenticity of host ... can't be established" challenge

Recently while writing new Android code I decided that it's the highest time to have a Git repository not only on my hard drive, but also safe in the Internet. After quick search and finding out that I have accounts at almost every popular service that provides Git hosting, I figured out that one that covers everything I need (wiki, bug tracking, code hosting, forums) is the good old sourceforge. I used it also with no problems few months ago on another mobile project, so I was hoping that pushing code there will be a piece of cake. But then when I tried to do it (after configuring the project on the sourceforge site), I got very interesting error: ssh://USER@git.code.sf.net:22: org.eclipse.jgit.transport.CredentialItem$YesNoType:The authenticity of host 'git.code.sf.net' can't be established. RSA key fingerprint is 86:7b:1b:12:85:35:8a:b7:98:b6:d2:97:5e:96:58:1d. Are you sure you want to continue connecting? In theory it's nothing bad, you press the "Y...

Force.com REST API getting token with curl

Force REST API usage with curl is really well documented, there are at least two official HowTO's, but both of the assume that you will get your OATH token with Java. Below I've described steps required to get the token and verify your token with curl. 1. Retrieve token curl -v -k https://DOMAIN.salesforce.com/services/oauth2/token -d "grant_type=password" -d "client_id=CONSUMER_KEY" -d "client_secret=CONSUMER_SECRET" -d "username=USERNAME" -d "password=USER_PASSWORDSECURITY_TOKEN" where: DOMAIN - is your salesforce domain (e.g. na9) CONSUMER_KEY, CONSUMER_SECRET - as taken from App Setup -> Develop -> Remote Access USERNAME, USER_PASSWORD, SECURITY_TOKEN - properties for the user that you want to connect with. Note that USER_PASSWORD and SECURITY_TOKEN are concatenated. Note that I used -k parameter in curl which results in the SSL certificate validation skipped (otherwise you need to add it or t...

Visualforce - COUNT() vs COUNT_DISTINCT()

Having COUNT_DISTINCT() is a great advantage in apex over standard Salesforce reporting capabilities. Still what you need to remember is that it doesn't return Integer (as COUNT() is doing), but List<AggregateResult> with count stored in the expr0 attribute of the first element of the list. So while the following code is valid: public String getObjectsForSelectedApplication() { return String.valueOf([SELECT COUNT() FROM MyObjects__c WHERE Application__c = :selectedApplication]); } The following code will return a list: public String get UniqueUsersForSelectedApplication() { return String.valueOf([SELECT COUNT_DISTINCT(User__c) FROM MyObjects__c WHERE Application__c = :selectedApplication]); } What you need to do is take the count from the list, for example with the following code: public String getUniqueUsersForSelectedApplication() { List&ltAggregateResult&gt result = [SELECT COUNT_DISTINCT(User...

Visualforce - actionSupport for hiding/showing elements of the page

While working on a Visualforce page that would automatically show/hide parts of its content I've stumbled upon problems with actionSupport. So the following code doesn't work (to be precise - the "details" pageBlock is not rerendered upon change in the select element): <apex:pageBlock> <apex:form> <apex:selectList value="{! selectedApplication}" size="1">  <apex:actionSupport event="onchange" reRender="details"/>  <apex:selectOptions value="{! availableApplications}"></apex:selectOptions>               </apex:selectList>  </apex:form>  </apex:pageBlock>  <apex:pageBlock id ="details" title="Details for {! selectedApplication}" rendered="{! NOT(ISNULL(selectedApplication))}">  </apex:pageBlock> After googling a bit I've stumbled upon posts suggesting that this happens if you try to rerender page...