Tag Archives: source

Some Basic Java Script

Hi guys, I thought of learning some Java Script as it has become one of the most important aspect of a programer in the present. So I thought of handling some basic default functions for a start. Hope you guys achieve some thing out from this post.

So here we will see how to write JavaScript inside the Basic html inside Body tag. We will see the external Java Script in another Tutorial.

So here we define the Script Tag inside the body and Write all the code explained between the Script Tags.

noscript tag is attached to inform people who are viewing this site in a browser that does not support Java Script.

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>

<script language="javascript" type="text/javascript">

//Java Scrip Code Goes Here
</script>

<noscript><h3>This site needs Javascript Enabled Browser</h3></noscript>

</body>
</html>

So below are some basic Java Script code you can try yourself

1. A simple Alert

alert("Hi this is amalan");

2. Min and Max number supported by JS

document.write(Number.MAX_VALUE + "<br/>");
document.write(Number.MIN_VALUE + "<br/>");

3. Printing a String

var sampl_str = "Here are some Escape charecters \" \t \' \\ \n";
document.write(sampl_str + "</br>");

4. Combining Strings

var first_String = "First String";
var second_String = "Second String";
var combined_String = first_String + second_String ;
document.write(combined_String + "</br>");

5. Example of using substring function

document.write("Sub String " + combined_String.substring(12, 18) + "</br>");

6. Getting the Last character

document.write("Last Charecter =" + combined_String.charAt(combined_String.length-1) + "</br>");

7.Usage of Indexof function

document.write("Index of " + combined_String.indexOf('t') + "</br>");

8.Variables

var str_var = "5";
var num_var = 10;

var total = num_var + str_var;
var multy = num_var * str_var;

document.write("Total is :" + total+"</br>");
document.write("Multy is :" + multy+"</br>");

9.Force data type conversion

total = num_var + Number(str_var);
document.write("Total is :" + total+"</br>");

total = num_var + num_var;
document.write("Total is :" + total+"</br>");

total = num_var + String(num_var);
document.write("Total is :" + total+"</br>");

10. Float

var float_var = 3.1417376464646464;
var float_str = float_var.toFixed(7);
document.write("Shortened PI value by 7 : "+float_str+"</br>");

document.write("Data type of float_var = "+typeof(float_var)+"</br>");
document.write("Data type of float_str = " + typeof(float_str) + "</br>");

11.Boolean

var bool_var = Boolean(23);
document.write("Booloean of 23 is " + bool_var + "</br>");

12. Compare Variables

var rand_num1 = 5;
var rand_num2 = 10;

document.write("5 > 10 = "+(rand_num1 > rand_num2)+"</br>");
document.write("5 >= 10 = "+(rand_num1 >= rand_num2)+"</br>");
document.write("5 == 10 = "+(rand_num1 == rand_num2)+"</br>");
document.write("5 <= 10 = "+(rand_num1 <= rand_num2)+"</br>");
document.write("5 < 10 = "+(rand_num1 < rand_num2)+"</br>");
document.write("5 != 10 = "+(rand_num1 != rand_num2)+"</br>");

13.Logical operators

document.write("Is 5 < 10 and 5 != 10 "+((rand_num1 < rand_num2) && (rand_num1 != rand_num2))+"</br>");
document.write("Is 5 > 10 or 5 != 10 "+((rand_num1 > rand_num2) || (rand_num1 != rand_num2))+"</br>");
document.write("Is 5 < 10"+ !(rand_num1 < rand_num2)+"</br>");

 

14.Arrays

var vehihcals = new Array("Car", "Van","Bus");
document.write("Second Value of the Vehical Array is :" + vehihcals[1]+"</br>");

15.Cycle through Array

for (i in vehihcals) {

document.write("vehical value "+ (Number(i)+1)+" is "+vehihcals[i]+"</br>");

}

16.Conditional Opperators

var rand_var = (5 < 10) ? "5 is less than 10" : "5 is greater than 10";
document.write(rand_var + "</br>");

17.if Else

if (5 > 5) {
document.write("5 is greater than 10"+"</br>");
}

else if (5 < 5) {
document.write("5 is less than 10"+"</br>");
}
else {
document.write("Both are Equal"+"</br>");
}

18.Switch Case

var state = "Colombo";

switch (state) {
case "Kandy":
document.write("Colder than Me" + "</br>");
break;

case "Colombo":
document.write("Same as Me" + "</br>");
break;

default:
document.write("I dont know what you have entered"+"</br>");
}

19.loop

var count = 1;

while (count <= 10) {
document.write(count+"</br>");
count++;
}

20.Continue Statement

var count = 1;

while (count <= 10) {


//try break
//if (count == 6) {
//    break;
//}

if (count % 2) {
count++;
continue;
}

document.write(count + "</br>");
count++;
}

21.doWhile

var count = 10;

do {
document.write(count + "</br>");
count--;
} while (count > 10);

22.for

for (var count = 0; count <= 10; count++) {
document.write(count+"</br>");
}

 

Get the Code here : Download code

Reference : YouTube Reference

Lets try Android Game Development with AndEngine

Hi Guys, this time I am back with some Android Game Development. I got this idea after, the popular game Flappy Bird. Hope all may have tried that game…!
Ok, so I wanted to develop a game and I did some researches and found out that there are a lot of Game engines out there.  Some of them are COCOS2D, AndEngine, libGDX and many others. In this article I’ll guild you using AndEngine which is a bit easier one. In future I’ll write on libGDX.

Assumption : I assume that you guys know how to install eclipse development environment, configure java path and install Android plugin to eclipse. This post does not cover all those basic steps.

Advise : As this is a kind of a crash course, its advisable to create files the same name as I use(But it is not mandatory).

Expected Outcome : You will be able to create some lines using the AndEngine

Step 1
Download the Source(library) for the AndEngine using this link and extract
https://github.com/nicolasgramlich/AndEngine

Step 2
Create a new project and when creating select ‘Android Project from Existing Code’ and in it select the folder that we extracted in the Step1.
existing code

This is a library project. Actually this library is the ANDENGINE.
libraryproject

You can check it by right clicking on the project we created now and going to the Android tab. You can see the ‘Is Library’ check box ticked.

Step 3
Now create a new Android project and un tick the create activity. Because we are going to create AndEngine activity using the library project we created above.
createactivity

Step 4
Now you have a project with empty src folder. Right click on that folder and create a new package when naming the package use the package name available in that project ManifestFile
packagename

In my case package name is ‘”com.batz.andengsample”‘

Step 4
Now in side the empty package Download or copy the code and create LineEample.java activity using this LineExample Source Code.

You will get some errors, but don’t worry we will fix it in the next step.

Step 5
So now in your project, right click and go to Android tab and there in the below section(library section), click on the add button and select the AndEngine project and press ok. And then press Apply.
add library

Now all the errors may have gone. Some times you will have errors on the package name, if you have used your own name. So for that, click on the package name that shows as error, click ctrl key +1 key , which will bring suggestion to create a package name according to yours, and click on it to create it. And hopefully all the bugs will be fixed.

Step 6
Before going for the app launch, we have to do one more important thing, we have to specify the activity we created now in the manifest file as a launcher

So go to the manifest file and add these lines between the application tags

         <activity
android:name=”.LineExample”>
<intent-filter>
<action android:name=”android.intent.action.MAIN” />
<category android:name=”android.intent.category.LAUNCHER” />
</intent-filter>
</activity>
manifest

LineExample is the name I gave for the activity we created, so in your one don’t forget to change that

Step 7
Now you are ready to run the app. So while you are in the the activity try running the app. it should bring a screen where you will see lots of random lines.

Step 8(For people getting error saying cannot find andengine.apk)
For some people the AndEngine folder is not getting added as library on the time of building the app. So at that point what you can do is copy the andengine.jar file from the AndEngine project libs folder and copy it into your projects’s libs folder. And right click on the newly added andengine.jar file and click on ‘Add to Build Path’ option. This is how the project structure looks after I added the jar to my project from the AndEngine project in the Step8

projectstructure

AndEngine Resources : http://www.andengine.org/

For people who got more time , for people who needs more detailed instruction on the same project guild please watch this tutorial video
Development Reference : http://www.youtube.com/watch?v=Q0kjiIH6u-M

Thank You
Happy Coding…!

-Batz-

Sony Xperia Illumination Bar Code(Some Code that May Interest you)

Here in this blog I am adding the illumination bar control activity class which I hacked and got from the famous Illumination bar App for Sony Xperia Android Phones. Hope you can get the basic Idea of the classes you have to access to take control of the lights Happy Coding.

If you are new to Illumination Bar App try it in the Google Play App Store

If you want to know how to hack an Android App step by step, please check my Blog on Android App Hacking

Thank You

illuminationcontrol.java

package com.rundgong.illuminationcontrol;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.ContextWrapper;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.Iterator;

public class IlluminationControlActivity extends Activity
{
public static final int LED_RGB = 1;
public static final int LED_WHITE = 0;
public static boolean sAccessibilityIsMissing = false;
public static final int sWhitePos = 6;
public static int testBlinkCounter = 0;
BooleanItemSummary mAlwaysOnSummary;
ArrayList mAppConfigs;
ArrayList mAppNotificationDatas = getDefaultApps();
GeneralSettingsSummary mGeneralSettingsSummary;
LinearLayout.LayoutParams mLayoutParams;
View mMainView;
NightModeSummary mNightModeSummary;
ArrayList mPhoneConfigs;
SelectThemeColorSummary mSelectThemeColorSummary;
BooleanItemSummary mTempDisable;

static
{
sAccessibilityIsMissing = true;
}

private void addAppNotifications()
{
LinearLayout localLinearLayout = (LinearLayout)this.mMainView.findViewById(2131165198);
localLinearLayout.removeAllViews();
localLinearLayout.addView(getHeadlineView(getString(2131034117)), this.mLayoutParams);
Iterator localIterator1 = this.mAppNotificationDatas.iterator();
Iterator localIterator2;
if (!localIterator1.hasNext())
localIterator2 = new UserApps(this).mUserApps.iterator();
while (true)
{
if (!localIterator2.hasNext())
{
return;
AppNotificationData localAppNotificationData1 = (AppNotificationData)localIterator1.next();
ConfigItemSummary localConfigItemSummary1 = new ConfigItemSummary(this, localAppNotificationData1.displayName, localAppNotificationData1.packageId, true);
localLinearLayout.addView(localConfigItemSummary1, this.mLayoutParams);
this.mAppConfigs.add(localConfigItemSummary1);
break;
}
AppNotificationData localAppNotificationData2 = (AppNotificationData)localIterator2.next();
ConfigItemSummary localConfigItemSummary2 = new ConfigItemSummary(this, localAppNotificationData2.displayName, localAppNotificationData2.packageId, true);
localLinearLayout.addView(localConfigItemSummary2, this.mLayoutParams);
this.mAppConfigs.add(localConfigItemSummary2);
}
}

static void fileLog(CharSequence paramCharSequence)
{
}

static int getBaseIntensity(int paramInt)
{
int i = 255;
switch (paramInt)
{
case 6:
default:
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
}
while (true)
{
return i;
i = 4;
continue;
i = 8;
continue;
i = 17;
continue;
i = 34;
continue;
i = 79;
continue;
i = 143;
}
}

static BlinkData getBlinkTimeFromPosition(int paramInt)
{
BlinkData localBlinkData;
switch (paramInt)
{
default:
localBlinkData = new BlinkData(0, 0);
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
}
while (true)
{
return localBlinkData;
localBlinkData = new BlinkData(0, 0);
continue;
localBlinkData = new BlinkData(1000, 1000);
continue;
localBlinkData = new BlinkData(500, 500);
continue;
localBlinkData = new BlinkData(150, 150);
continue;
localBlinkData = new BlinkData(2000, 2000);
continue;
localBlinkData = new BlinkData(2000, 5000);
continue;
localBlinkData = new BlinkData(2000, 10000);
continue;
localBlinkData = new BlinkData(2000, 30000);
continue;
localBlinkData = new BlinkData(2000, 60000);
}
}

static int getColorFromPosition(int paramInt1, int paramInt2)
{
int i = getBaseIntensity(paramInt2);
int j;
switch (paramInt1)
{
default:
j = -1;
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
}
while (true)
{
return j;
j = -16777216 + 65536 * i;
continue;
j = -16777216 + i * 256;
continue;
j = -16777216 + i;
continue;
j = -16777216 + 65536 * i + i * 256;
continue;
j = i + (-16777216 + i * 256);
continue;
j = i + (-16777216 + 65536 * i);
continue;
j = i + (-16777216 + 65536 * i + i * 256);
}
}

static ArrayListgetDefaultApps()
{
ArrayList localArrayList = new ArrayList();
localArrayList.add(new AppNotificationData("com.android.calendar", "Calendar"));
localArrayList.add(new AppNotificationData("com.android.email", "Email"));
localArrayList.add(new AppNotificationData("com.facebook.katana", "Facebook"));
localArrayList.add(new AppNotificationData("com.google.android.gm", "Gmail"));
localArrayList.add(new AppNotificationData("com.google.android.apps.plus", "Google+"));
localArrayList.add(new AppNotificationData("com.google.android.gsf", "Google Talk"));
localArrayList.add(new AppNotificationData("com.twitter.android", "Twitter"));
localArrayList.add(new AppNotificationData("com.whatsapp", "WhatsApp"));
return localArrayList;
}

static int getDefaultLedNumForDevice()
{
if (Build.MODEL.contains("ST25"));
for (int i = 1; ; i = 0)
return i;
}

private TextView getHeadlineView(String paramString)
{
TextView localTextView = new TextView(this);
localTextView.setGravity(17);
localTextView.setText(paramString);
localTextView.setBackgroundColor(-12303292);
localTextView.setTextColor(-1);
return localTextView;
}

static String getLedIdFromNumber(int paramInt)
{
if (paramInt == 1);
for (String str = "com.sonyericsson.illumination.intent.extra.value.BUTTON_RGB"; ; str = "com.sonyericsson.illumination.intent.extra.value.BUTTON_2")
return str;
}

public static void illuminate(ContextWrapper paramContextWrapper, int paramInt1, int paramInt2, BlinkData paramBlinkData, int paramInt3)
{
Intent localIntent;
if ((paramBlinkData == null) || (paramBlinkData.onTime == 0))
{
localIntent = new Intent("com.sonyericsson.illumination.intent.action.START_LED");
 localIntent.putExtra("com.sonyericsson.illumination.intent.extra.LED_ON_TIME", paramInt2);
}
while (true)
{
localIntent.putExtra("com.sonyericsson.illumination.intent.extra.PACKAGE_NAME", "com.rundgong.illuminationcontrol");
 localIntent.putExtra("com.sonyericsson.illumination.intent.extra.LED_ID", getLedIdFromNumber(paramInt3));
 localIntent.putExtra("com.sonyericsson.illumination.intent.extra.LED_COLOR", paramInt1);
 paramContextWrapper.startService(localIntent);
 return;
 localIntent = new Intent("com.sonyericsson.illumination.intent.action.START_LED_PULSE");
 localIntent.putExtra("com.sonyericsson.illumination.intent.extra.LED_NO_OF_PULSES", paramInt2 / (paramBlinkData.offTime + paramBlinkData.onTime));
 localIntent.putExtra("com.sonyericsson.illumination.intent.extra.LED_PULSE_ON_TIME", paramBlinkData.onTime);
 localIntent.putExtra("com.sonyericsson.illumination.intent.extra.LED_PULSE_OFF_TIME", paramBlinkData.offTime);
}
}

private void refreshGUI()
{
this.mNightModeSummary.update();
this.mSelectThemeColorSummary.update();
Iterator localIterator = this.mPhoneConfigs.iterator();
while (true)
{
if (!localIterator.hasNext())
{
addAppNotifications();
return;
}
((ConfigItemSummary)localIterator.next()).update();
}
}

private void startBackgroundService()
{
startService(new Intent(this, BackgroundService.class));
startService(new Intent(this, NotificationService.class));
}

public void addMoreAppsButtonClicked(View paramView)
{
startActivity(new Intent(this, AddAppsActivity.class));
}

public void donateButtonClicked(View paramView)
{
startActivity(new Intent("android.intent.action.VIEW", Uri.parse("https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=H7LW4D3XWK9GC")));
}

AlertDialog getAccessibilityDialog()
{
AlertDialog.Builder localBuilder = new AlertDialog.Builder(this);
localBuilder.setMessage(2131034157).setCancelable(false).setPositiveButton("Yes", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface paramDialogInterface, int paramInt)
{
IlluminationControlActivity.this.startActivity(new Intent("android.settings.ACCESSIBILITY_SETTINGS"));
}
}).setNegativeButton("No", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface paramDialogInterface, int paramInt)
{
paramDialogInterface.cancel();
}
});
return localBuilder.create();
}

public void helpButtonClicked(View paramView)
{
startActivity(new Intent(this, HelpActivity.class));
}

public void onCreate(Bundle paramBundle)
{
super.onCreate(paramBundle);
this.mMainView = ((LayoutInflater)getSystemService("layout_inflater")).inflate(2130903043, null);
setContentView(this.mMainView);
this.mGeneralSettingsSummary = new GeneralSettingsSummary(this);
this.mAlwaysOnSummary = new BooleanItemSummary(this, getString(2131034129), "keyLightAlwaysOn");
this.mTempDisable = new BooleanItemSummary(this, getString(2131034130), "tempDisableIllumination");
this.mTempDisable.setEnableText(2131034131);
this.mTempDisable.setDisableText(2131034132);
this.mNightModeSummary = new NightModeSummary(this);
this.mSelectThemeColorSummary = new SelectThemeColorSummary(this);
this.mPhoneConfigs = new ArrayList();
this.mAppConfigs = new ArrayList();
startBackgroundService();
this.mLayoutParams = new LinearLayout.LayoutParams(-1, -2);
this.mLayoutParams.setMargins(0, 1, 0, 0);
LinearLayout localLinearLayout1 = (LinearLayout)this.mMainView.findViewById(2131165196);
localLinearLayout1.addView(getHeadlineView(getString(2131034114)), this.mLayoutParams);
localLinearLayout1.addView(this.mGeneralSettingsSummary, this.mLayoutParams);
localLinearLayout1.addView(this.mAlwaysOnSummary, this.mLayoutParams);
localLinearLayout1.addView(this.mTempDisable, this.mLayoutParams);
localLinearLayout1.addView(this.mNightModeSummary, this.mLayoutParams);
localLinearLayout1.addView(this.mSelectThemeColorSummary, this.mLayoutParams);
LinearLayout localLinearLayout2 = (LinearLayout)this.mMainView.findViewById(2131165197);
localLinearLayout2.addView(getHeadlineView(getString(2131034116)), this.mLayoutParams);
ConfigItemSummary localConfigItemSummary1 = new ConfigItemSummary(this, "SMS", "sms", false);
this.mPhoneConfigs.add(localConfigItemSummary1);
localLinearLayout2.addView(localConfigItemSummary1, this.mLayoutParams);
ConfigItemSummary localConfigItemSummary2 = new ConfigItemSummary(this, "Missed Calls", "missedCalls", false);
localLinearLayout2.addView(localConfigItemSummary2, this.mLayoutParams);
this.mPhoneConfigs.add(localConfigItemSummary2);
ConfigItemSummary localConfigItemSummary3 = new ConfigItemSummary(this, "Battery Full", "batteryFull", false);
localLinearLayout2.addView(localConfigItemSummary3, this.mLayoutParams);
this.mPhoneConfigs.add(localConfigItemSummary3);
ConfigItemSummary localConfigItemSummary4 = new ConfigItemSummary(this, "Battery Empty", "batteryEmpty", false);
localLinearLayout2.addView(localConfigItemSummary4, this.mLayoutParams);
this.mPhoneConfigs.add(localConfigItemSummary4);
}

public void onResume()
{
super.onResume();
refreshGUI();
if (sAccessibilityIsMissing)
getAccessibilityDialog().show();
}

public static class BlinkData
{
int offTime = 0;
int onTime = 0;

public BlinkData(int paramInt1, int paramInt2)
{
this.onTime = paramInt1;
this.offTime = paramInt2;
}
}
}

Let’s Hack Android Apks

Ok guys i know many of you have tried to hack android apks using APK tool, but is it a success????
No I don’t think so you get a encrypted code, but you get the images out of it.

But here I am gona guid you using 2 tools
one is Dex2JAR and the other one is the JD GUI
Download Dex2JAR here
Download JDGUI here

Ok now I hope you know how to get an apk file from an Android App, the easiest way is to use the App Super Backup app available in the Google Market.

1.Get the APK from your phone memory card , where the Super Backup normally puts the apk.

2.Extract the DEX2JAR file

3.copy the APK file you want to extract code in to that file

4.now open the command prompt and change the directory

(command to change directory in command prompt”cd C:\Users\Amalan\Desktop\dex2jar-0.0.9.9\dex2jar-0.0.9.9″)to the directory where you have copied your APK in my case the directory is “C:\Users\Amalan\Desktop\dex2jar-0.0.9.9\dex2jar-0.0.9.9”

5.now to convert the APK to JAR type this command “dex2jar.bat ‘yourapp.apk’ ” and press enter and you will get the JAR file of your APK.

6.now extract the JDGUI and there you will find ‘jd-gui’ exe file, run it

7.now drag and drop the JAR file you just created, Voila you will find all the code in it. Not a Single Encryption the total code is available to you.

8.here you wont get any drawable files, for that use APK TOOL or just rename the ‘.apk’ to ‘.rar’ and extract and you can take all the images.

Thats it you have successfully Extracted the full source code out of your favorite Android App