Monday, May 6, 2013

Changes/deprecations (without additions) from API 16 to 17 - Android 4.1 to 4.2

Hello,

This post is nothing much, I have just used the reference: http://developer.android.com/sdk/api_diff/17/changes.html to get the changes/ deprecations without the additions from Android API 16 to 17.  Using this you should be able to see the changes/deprecations without actually having to click on the individual links. However if you find what you are looking for in this post, go to the above link and verify just to be sure and to do a quality job. I captured it to the best of my ability :) .
This post will be useful if you are looking at setting your code target to 17 and do not want to see any deprecations. Hope this helps :) 

Class android.app.PendingIntent


Changed Methods
String getTargetPackage()
Now deprecated.

Class android.appwidget.AppWidgetProviderInfo


Changed Methods
AppWidgetProviderInfo clone()
Change in return type from Object toAppWidgetProviderInfo.
Change in exceptions thrown from
java.lang.CloneNotSupportedException to no exceptions.
Method was inherited from 
java.lang.Object, but is now defined locally. Change of visibility from protected to public.



Class android.bluetooth.BluetoothA2dp


Changed Methods
void finalize()
Change in exceptions thrown from java.lang.Throwable to no exceptions.
Method was inherited from 
java.lang.Object, but is now defined locally. Change of visibility from protected to public.



Class android.content.Context

Changed Fields
Now deprecated.

Now deprecated.

Class android.content.IntentSender


Changed Methods
String getTargetPackage()
Now deprecated.

 

Class android.database.DatabaseUtils.InsertHelper

Removed Fields
int TABLE_INFO_PRAGMA_DEFAULT_INDEX


 

Class android.hardware.Sensor

Change from non-final to final.

Class android.location.LocationProvider


Changed Methods
int getAccuracy()
Changed from abstract to non-abstract.

Changed from abstract to non-abstract.

boolean hasMonetaryCost()
Changed from abstract to non-abstract.

Changed from abstract to non-abstract.

boolean requiresNetwork()
Changed from abstract to non-abstract.

boolean requiresSatellite()
Changed from abstract to non-abstract.

Changed from abstract to non-abstract.

boolean supportsBearing()
Changed from abstract to non-abstract.

boolean supportsSpeed()
Changed from abstract to non-abstract.

Class android.net.LocalSocket

Added interface java.io.Closeable.



Class android.os.PowerManager


Changed Fields
Now deprecated.

Now deprecated.


Class android.os.PowerManager.WakeLock

Change from non-final to final.

Class android.provider.Settings.Secure


Changed Fields
String ADB_ENABLED
Now deprecated.

String BLUETOOTH_ON
Now deprecated.

String DATA_ROAMING
Now deprecated.

Now deprecated.

Now deprecated.

String HTTP_PROXY
Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.

String WIFI_ON
Now deprecated.

Now deprecated.


Class android.provider.Settings.System


Changed Methods
boolean getShowGTalkServiceStatus(ContentResolver)
Now deprecated.

void setShowGTalkServiceStatus(ContentResolver,boolean)
Now deprecated.


Changed Fields
Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.

String DEBUG_APP
Now deprecated.

String DIM_SCREEN
Now deprecated.

String MODE_RINGER
Now deprecated.

Now deprecated.

String RADIO_CELL
Now deprecated.

String RADIO_NFC
Now deprecated.

String RADIO_WIFI
Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.


Class android.text.format.DateFormat

Changed Methods
Change from final to non-final.

char[] getDateFormatOrder(Context)
Change from final to non-final.

DateFormat getLongDateFormat(Context)
Change from final to non-final.

DateFormat getMediumDateFormat(Context)
Change from final to non-final.

DateFormat getTimeFormat(Context)
Change from final to non-final.

CharSequence format(CharSequence,Calendar)
Change from final to non-final.

CharSequence format(CharSequence, Date)
Change from final to non-final.

CharSequence format(CharSequence, long)
Change from final to non-final.


Class android.text.format.DateUtils

Changed Methods
String getAMPMString(int)
Now deprecated.

String getDayOfWeekString(int, int)
Now deprecated.

String getMonthString(int, int)
Now deprecated.


Changed Fields
Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.

Now deprecated.



Class android.view.Display

 

Changed Methods
Now deprecated.
           

Class android.view.Surface

Changed Methods
void unlockCanvas(Canvas)
Now deprecated.


Class android.view.View


Removed Fields
int TEXT_ALIGNMENT_RESOLVED_DEFAULT



Class android.view.WindowManager.LayoutParams

Changed Fields
Now deprecated.



Package android.webkit

Removed Classes
CacheManager

CacheManager.CacheResult


Changed Classes







Class android.webkit.WebChromeClient

Changed Methods
boolean onJsTimeout()
Now deprecated.

 

Class android.webkit.WebHistoryItem

Removed Methods
int getId()


Class android.webkit.WebSettings

Removed Methods
boolean getNavDump()

boolean getUseDoubleTree()

boolean getUseWebViewBackgroundForOverscrollBackground()

int getUserAgent()

void setNavDump(boolean)

void setUseDoubleTree(boolean)

void setUseWebViewBackgroundForOverscrollBackground(boolean)

void setUserAgent(int)


Changed Methods
Now deprecated.

Now deprecated.


Changed Fields
Now deprecated.


Class android.webkit.WebView

Changed Constructors
WebView(Context, AttributeSet, int,boolean)
Now deprecated.


Removed Methods
void debugDump()

void disablePlatformNotifications()

void emulateShiftHeld()

void enablePlatformNotifications()

int getVisibleTitleHeight()

boolean restorePicture(Bundle, File)

boolean savePicture(Bundle, File)


Changed Methods
boolean canZoomIn()
Now deprecated.

boolean canZoomOut()
Now deprecated.

float getScale()
Now deprecated.

void setCertificate(SslCertificate)
Now deprecated.

Now deprecated.


 

Class android.webkit.WebViewDatabase

Removed Fields
String LOGTAG


Class android.widget.CheckedTextView

Removed Methods
void onPaddingChanged(int)


Class android.widget.DigitalClock

Now deprecated.

Class android.widget.SlidingDrawer

Now deprecated.

Class android.widget.TextView

Removed Methods
void resetResolvedDrawables()

void resolveDrawables()


Changed Methods
void setPaddingRelative(int, int, int,int)
Method was locally defined, but is now inherited from View.


Class android.widget.TwoLineListItem

Now deprecated.

Tuesday, April 23, 2013

Android PUSH: GCM error: Missing registration_ids field

Hello,                                                                        

When trying to send the registration_id in the format requested in the site I got the error: 'Missing registration_ids field'. Sending it as an array worked as shown below.

Initial: 
Content-Type:application/json
Authorization:key=AIzaSyB-1uEai2WiUapxCs2...

{
  "registration_id" : "APA91bHun4MxP5egoKMwt2KZF....",
  "data" : {
    "Team" : "Portugal",
    "Score" : "3",
    "Player" : "Varela",
  },
}
Gives the following error: Missing "registration_ids" field

Use:                                                                            {
  "registration_ids" : ["APA91bGSnrAvxspEngNfGqd4JDsl00..."],
  "data" : {
    "Team" : "Portugal",
    "Score" : "3",
    "Player" : "Varela",
  },
}

Hope this helps !

Sunday, April 21, 2013

Support Apostrophes in Android Application names \ strings.xml file

Hello,

If you want to support apostrophes in your Android application name (or another field in your strings.xml file) and have got an error, take a look at the information below.

Application names do not support the apostrophe by default. An application name in the strings.xml file (res > values > strings.xml) in the format:


<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Who's there</string>

Will give you an error.

If you want to support this you can try escaping the apostrophe:


<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Who\'s there</string>
(this hint is already there in Eclipse if you hover the mouse over the red cross in the strings.xml file)

else you can enclose the full name in double quotes:


<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">"Who's there"</string>



Hope this helps and makes your life easier ! :)




XML manipulation in C# - reading from two nodes, concatenating them and adding the value as a new node.

Hello,

I am a C# beginner and I had the requirement of reading two nodes from an XML file concatenating them and inserting the concatenated value in a new node.

The code I used is given below, and hopefully will help you to get your task done (which should not be an evil purpose :) ). The sample XML used can be found below the code.

What is being done:
- Read the values from a node and add them to a list (using XmlNodeList and List<string>).
- Do the same for the other node from which I need the values.
- Concat the values of the two lists above.
- Add the concatenated values as a new node to the XML (using XmlDocument 's CreateNode method).

Code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.XPath;
using System.IO;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
//use XmlDocument to access the XML
            XmlDocument xmlDoc = new XmlDocument();
            //xmlDoc.Load("C:\\Documents and Settings\\learner\\Desktop\\Daily\\XML\\A.xml");
            xmlDoc.LoadXml(response);

//Get the node list into a XmlNodeList object using XmlDocument 's SelectNodes method
            XmlNodeList CustomerNumList = xmlDoc.SelectNodes("//CustomerChosen/Customer/CustomerID/CustomerNo/text()");

            List<string> numberVals = new List<string>();

//Iterate the XmlNodeList
            for (int i = 0; i < CustomerNumList.Count; i++)
            {
                numberVals.Add(CustomerNumList[i].Value);
            }

            List<string> functionCodeVals = new List<string>();

//same as above - but a different node
            XmlNodeList CustomerFunctionList = xmlDoc.SelectNodes("//CustomerChosen/Customer/CustomerFunction/Code/text()");
            for (int i = 0; i < CustomerFunctionList.Count; i++)
            {
                functionCodeVals.Add(CustomerFunctionList[i].Value);
            }

            List<string> concatNumCodes = new List<string>();

//Concatenating here
            for (int i = 0; i < numberVals.Count; i++)
                concatNumCodes.Add(numberVals[i] + "-" + functionCodeVals[i]);

            string concatNumCodeString = String.Join(",", concatNumCodes);
           

            XmlNodeList CustomerSelectionList = xmlDoc.SelectNodes("//CustomerSelection/Customer");
            for (int i = 0; i < CustomerSelectionList.Count; i++)
            {
//making a new node here using XmlDocument's CreateNode method
                XmlNode nodeDeterminedCustomers = xmlDoc.CreateNode("element", "DeterminedCustomers", "");
                nodeDeterminedCustomers.InnerText = concatNumCodeString;
                CustomerSelectionList[i].AppendChild(nodeDeterminedCustomers);

            }

            Console.WriteLine(concatNumCodeString);
            xmlDoc.Save(Console.Out);
            Console.ReadLine();
// sharing to make your life easy, hope this helps ! good luck :)

        }

    }

}



XML:
<SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP:Body>
      <ns0:CustomerDetermByElemResp xmlns:ns0="http://learner.com/CRM/BusinessCustomer">
        <CustomerChosen>
            <Customer>
               <CustomerID>
                  <CustomerNo>6321565426</CustomerNo>
                  <CustomerGUID>00000000000000000000000000000000</CustomerGUID>
               </CustomerID>
               <DocumentID>00000000000000000000000000000000</DocumentID>
               <CustomerFunction>
                  <Code>00000003</Code>
               </CustomerFunction>
               <IsMainCustomer>true</IsMainCustomer>
               <RelatedCustomerID>
                  <CustomerGUID>00000000000000000000000000000000</CustomerGUID>
               </RelatedCustomerID>
               <DeterminationTypeCode>2</DeterminationTypeCode>
            </Customer>
            <Customer>
               <CustomerID>
                  <CustomerNo>5236214589</CustomerNo>
                  <CustomerGUID>00000000000000000000000000000000</CustomerGUID>
               </CustomerID>
               <DocumentID>00000000000000000000000000000000</DocumentID>
               <CustomerFunction>
                  <Code>00000004</Code>
               </CustomerFunction>
               <IsMainCustomer>true</IsMainCustomer>
               <RelatedCustomerID>
                  <CustomerGUID>00000000000000000000000000000000</CustomerGUID>
               </RelatedCustomerID>
               <DeterminationTypeCode>2</DeterminationTypeCode>
            </Customer>
         </CustomerChosen>
         <CustomerSelection>
            <Customer>
               <CustomerID>
                  <CustomerNo>953216475</CustomerNo>
                  <CustomerGUID>DE435FD45T</CustomerGUID>
               </CustomerID>
               <DocumentID>00000000000000000000000000000000</DocumentID>
               <CustomerFunction>
                  <Code>00000015</Code>
                  <Text>Contact Person</Text>
               </CustomerFunction>
               <IsMainCustomer>true</IsMainCustomer>
               <RelatedCustomerID>
                  <CustomerGUID>00000000000000000000000000000000</CustomerGUID>
               </RelatedCustomerID>
               <CustomerDescription>0430 Peter</CustomerDescription>
               <CustomerAddress>1265 SriLanka</CustomerAddress>
               <DeterminationTypeCode>1</DeterminationTypeCode>
            </Customer>
            <Customer>
               <CustomerID>
                  <CustomerNo>2153654892</CustomerNo>
                  <CustomerGUID>E234R32ED4</CustomerGUID>
               </CustomerID>
               <DocumentID>00000000000000000000000000000000</DocumentID>
               <CustomerFunction>
                  <Code>00000123</Code>
                  <Text>Contact Person</Text>
               </CustomerFunction>
               <IsMainCustomer>true</IsMainCustomer>
               <RelatedCustomerID>
                  <CustomerGUID>00000000000000000000000000000000</CustomerGUID>
               </RelatedCustomerID>
               <CustomerDescription>0124 John</CustomerDescription>
               <CustomerAddress>1234 Srilanka</CustomerAddress>
               <DeterminationTypeCode>1</DeterminationTypeCode>
            </Customer>
         </CustomerSelection>
         <CustomerList/>
      </ns0:CustomerDetermByElemResp>
   </SOAP:Body>
</SOAP:Envelope>