Pages

Showing posts with label JAVA. Show all posts
Showing posts with label JAVA. Show all posts

Thursday, May 9, 2013

How to Add Advertisements to Your Android Applications Using Admob




  1. Create an AdMob account by browsing to http://www.admob.com
  2. 2
    Once your AdMob account is created, Login to your account.
  3. 3
    Click on sites & Apps tab on the top menu. Then click on Add Site/App button to add the application you want your advertisements to show up on.
  4. 4
    Select the platform your created application is, in this case select Android.
  5. 5
    Enter the required details to add an app to the list. You should already know the application name and the package name for your application. Therefore write the name of your application in the app name field, and write the android package URL as market://details?id=<Package name>. Enter your package name by replacing the <Package name >. For category select what type of app your application is, and write a small description in the description box to tell what type of app it is. There is also an option to include Google ads, which can be useful to get ad fills when AdMob ads are not displayed.
  6. 6
    Once you hit continue, AdMob will add your application to the list and ask you to download the AdMob Android SDK. Click on the download button to download the SDK.
  7. 7
    While AdMob SDK is downloading, click on the go to Sites/Apps button to return to your list applications, then click on manage settings on the listed app to find your publisher ID.
    Save this information for future use in Eclipse to incorporate AdMob in your application.
  8. 8
    Extract the downloaded .Zip file with the AdMob Android SDK to an easily accessible location.
  9. 9
    Now start your Eclipse IDE to import the downloaded SDK. Find the folder containing your Android application and right click to choose properties option.
  10. 10
    Select “Java Build Path” option from the navigation plan to your left and then click on “libraries tab” to add the SDK file. Click on “Add external JARS…” button and locate the unzipped AdMob SDK JAR file on your disk, and add it to your project.
  11. 11
    If you successfully completed the previous step, you should now see the JAR file located under, Referenced Libraries folder inside your project.
  12. 12
    Once the SDK is added to your project, open the AndroidManifest.xml file located in your project. In order to use AdMob in your application you must include the following xml Just before the </application> tag enter a new activity for com.google.ads.AdActivity by adding this xml.<activity android:name="com.google.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />”
  13. 13
    After the </application> tag enter permissions that are required by AdMob.<uses-sdk android:minSdkVersion="7" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
  14. 14
    Open the project.properties file in your Android application folder and change this line of code at the end of the file to make AdMob SDK work. AdMob SDK requires android SDK-13, and since our application was SDK-7 we require changing the target version, target=android-13.
  15. 15
    Finally, to add an AdMob advertisement to your application, open your desired layout xml file. For this tutorial we will just add it to our main.xml located under res/layout folder of our project. Then add this following xml where you like to show your ad in your layout.In <LinearLayout> tag add xmlns:ads= "http://schemas.android.com/apk/lib/com.google.ads" After the <LinearLayout> tag add <com.google.ads.AdView android:id="@+id/adView" android:layout_width="wrap_content" android:layout_height="wrap_content" ads:adSize="BANNER" ads:adUnitId="YOUR PUBLISHER ID" ads:loadAdOnCreate="true" > </com.google.ads.AdView>

Thursday, April 18, 2013

How to get source code from apk file


What is .apk file?
 APK file is nothing but Android Package File(APK). APK is the file format used to distribute and install application software and middleware on Google's Android operating system.


Apk Files are Zip file formatted packages based on the JAR file format, with .apk extension. Apk files contains all program resources and code i.e it contains .dex files, resources, assets, certificates, and manifest file.



How to get source (java files) from .apk file?
As we now know that apk file is just a zip file containing all program resource file, we can now get java code from apk files with ease. Following are steps to get java code from apk files.
Step 1:Renaming .apk file

  • Rename the .apk file with the extension .zip (for example let the file be "demofile.apk" then after renaming it becomes "demofile.apk.zip")

Step 2:Getting java files from apk

  • Now extract the renamed zip file in specific folder, for example let that folder be "demofolder".
  • Now Download dex2jar from the link for windows and extract that zip file in folder "demofolder".
  • Now open command prompt and go to the folder created in previous step and type the command "dex2jar classes.dex" and press enter.This will generate "classes.dex.dex2jar" file in the same folder.
  • Now  Download java decompiler from the link and extract it and start(double click) jd-gui.exe
  • From jd-gui window browse the generated "classes.dex.dex2jar" file in demofolder, this will give all the class files by src name.
  • Now from the File menu select "save all sources" this will generate a zip file named "classes_dex2jar.src.zip" consisting of all packages and java files.
  • Extract that zip file (classes_dex2jar.src.zip) and you will get all java files of the application.
Above steps will generate java files but to get xml files perform following steps.

Step 3:Getting xml files from apk

  • Download apktool and apktool install from the link and extract both files and place it in the same folder (for example "demoxmlfolder").
  • Place the .apk file in same folder (i.e demoxmlfolder)
  • Now open command prompt and goto  the directory where apktool is stored (here "demoxmlfolder") and type the command "apktool if framework-res.apk" 
  • Above command should result in "Framework installed ..."
  • Now in command prompt type the command "apktool d filename.apk" (where filename is name of apk file)
  • This will generate a folder of name filename in current directory (here demoxmlfolder) where all xml files would be stored in res\layout folder.

Saturday, April 13, 2013

Difference between Java and JavaScript


      Java is an object oriented programming language whereas JavaScript is more of a scripting language.

        JavaScript is used to make the web pages more interactive. However, Java can be used not only to make interactive web pages but can also be used to create server side applications and standalone programming.

        Java uses the concept of classes and objects that makes reuse of the code easier but there is no such thing in JavaScript.

      Java exhibits the properties like inheritance, data encapsulation and polymorphism whereas JavaScript does not.


Java vs JavaScript

Java and JavaScript are programming languages. Java is an object oriented programming language whereas JavaScript is more of a scripting language. Both can be used to make web pages more interactive. However, Java is also used to develop server side applications and standalone programming.
Java
Java is an object oriented programming language. In early 1990s, Sun Microsystems developed the Java language. Initially, it was designed to make small programs for the web browser called applets. But later on, Java was used to create applications based on e-commerce.
There are five main features of Java language:
• Provides more flexibility to develop software applications because of object oriented approach.
• Easy to use as it combines the best properties of other programming languages.
• Allows code written in Java to run on different platforms or Java code is independent of platform.
• The code from the remote source can be executed securely.
• Built-in support for computer networks.
Java also supports automated memory management model that allows developers to get rid of the time consuming method called manual memory management. Programmers can easily do this by implementing automatic garbage collection. But according to some people, Java is slow as well as consumes more memory than other programming languages such as C++.

JavaScript
JavaScript is also a programming language which is used to make web pages more dynamic as well as interactive. Constant downloads from the server are not required in case of JavaScript as it runs on the user’s computer. JavaScript is different from the Java programming language.
Most modern day web browsers have built-in JavaScript. However, JavaScript based web pages can run only if JavaScript is enabled on the web browser and the browser supports it. JavaScript is enabled in most browsers by default.
No special program is required in order to write code in JavaScript as it is an interpreted language. You can use any text editor such as Notepad in order to write JavaScript code. You can also use other text editor that colorizes the different codes making it easier to detect any error.
JavaScript is different from HTML because JavaScript is used to create more dynamic web pages while HTML is a markup language that is used to create static content on the web page.
You can insert the JavaScript code in a HTML file by using the <script> tag. But if you want to use the script in different pages of the website then you can save the scripts in different files with .js extension.