Thursday, March 24, 2011

Create new Activity in Eclipse

Vagy new Class.. vagy pedig:

  1. Double click on AndroidManifest.xml in the package explorer.
  2. Click on the "Application" tab of the manifest editor
  3. Click on "Add.." under the "Application Nodes" heading (bottom left of the screen)
  4. Choose Activity from the list in the dialog that pops up (if you have the option, you want to create a new top-level element)
  5. Click on the "Name*" link under the "Attributes for" header (bottom right of the window) to create a class for the new activity.

Android: Opening a New Screen

Itt van.

Tuesday, March 22, 2011

Android Adapterek

Itt van.

JSON parsing on Android

innen

  1. That comes with platform (org.json) – optimized since 2.2
  2. Jackson
  3. GSON
...
  1. org.json – Not very convenient to use. Doesn’t support stream parsing out of the box.
  2. jackson – very convenient to use, excellent mapping features, custom stream deserializers… but don’t use it on Android. Like Facebook and Twitter did… This will put you into the grave:) Everything is excellent before you will take a look into the ddms log.
  3. gson – GSON stream is very nice and small. It doesn’t produce so much garbage as Jackson. But it is not so convenient to use. Good news that GSON stream parser is included in API 11.

Android ListView examples

Krysztof Grajek: Custom ListView items and adapters

AppFulcrum:

2 dologra erdemes odafigyelni a sajat ArrayAdapterunkben. Egyreszt amikor a ListView egy sora lekerul a kijelzorol ezt a view-t megkapja az adapater es a getView(..) method convertView-jaban ujra megapjuk es fel tudjuk hasznalni. Masreszt a getView-ban hivott findViewByID() eleg koltseges ezert erdemes egy ViewHolder class-ban tarolni a findeViewByID() alltal talalt view-kat es ezt a convertView tag-jeben tarolni. Ezzel Lars Vogel szerint kb 175%-os performacianovekedeset erhetunk el. Valahogy igy:
// ViewHolder will buffer the assess to the individual fields of the row layout
static class ViewHolder {
public ImageView imageView;
public TextView textView;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if (null == convertView) {
LayoutInflater inflater = context.getLayoutInflater();
rowView = inflater.inflate(R.layout.rowlayout, null, true);
holder = new ViewHolder();
holder.textView = (TextView) rowView.findViewById(R.id.label);
holder.imageView = (ImageView) rowView.findViewById(R.id.icon);
rowView.setTag(holder);
} else {
holder = (ViewHolder) rowView.getTag();
}
holder.textView.setText("whatever text");
holder.imageView.setImageResource(R.drawable.testicon);
return convertView;
}

Monday, March 21, 2011

Android es Eclipse tutorialok

Android

dp to pixel (Android)

private int dpToPixel(float dp) {
int result;
final float scale = getResources().getDisplayMetrics().density;
result = (int) (dp * scale + 0.5f);
return result;
}

Thursday, March 17, 2011

Emulator-ban fut-e az Android code

Csak ezt talaltam:
if ("sdk".equals(Build.PRODUCT)) {...}

Android Location

LocationManager lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
Location loc = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER);
if (null != loc) {
Double longitude = loc.getLongitude();
Double latitude = loc.getLatitude();
}

A manifiest-be pedig:
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />

Ez az utolso csak akkor kell, ha LocationManager.GPS_PROVIDER helyett valami mock location provider-t akarunk hasznalni. Ezt meg valahogy igy tehejuk meg:

String MOCK_LOC_PROVIDER_NAME = "mockLocationProvider";
...
lm.addTestProvider(MOCK_LOC_PROVIDER_NAME, false, false, false, false, false, false, false, 0, 5);
Location location = new Location(MOCK_LOC_PROVIDER_NAME);
location.setLatitude(32.23434);
location.setLongitude(-16.32525);
location.setTime(new Date().getTime());
lm.setTestProviderLocation(MOCK_LOC_PROVIDER_NAME, location);
lm.setTestProviderEnabled(MOCK_LOC_PROVIDER_NAME, true);

Es igy nezhetjuk meg, hogy mar hozzaadtuk-e a sajat location provider-unket (2-szer ugyanazt nem lehet hozzaadni mert akkor hiba lesz):
List providers = lm.getAllProviders();
if (providers.contains(MOCK_LOC_PROVIDER_NAME)) {...}

Wednesday, March 16, 2011

Friday, March 11, 2011

AndEngine

This is the official WiKi for AndEngine -- the free 2D OpenGL Game Engine for the Android platform.

Readonly sdcard AVD-hez

Letrehoztam Eclipse-ben egy AVD-t (Android Virtual Device), de az sdcard-ja readonly volt. Probalkoztam mindenfelevel, de vegul az segitett, ha csinaltam egy uj AVD-t. Nem tudom mit rontottam el elsore, de ez a masodik mar nem volt read only. Itt viszont eloszor tul kicsi-t csinaltam (128 MB) amire nem tudtam felmasolni egy 7 MB-os mp4-et. Amikor csinaltam egy masik AVD-t 1024 MB-os sdcard-dal, akkor arra mar felment ez a file. (Viszont maga az AVD sokkal lassabban keszult el, mert sokaig tartott letrehozni az sdcard.img-t. Raadasul az AVD indulasanal is lassabban tolti be az sdcard-ot, ezert egy ideig itt is readonly-nak tunik.)

Monday, March 07, 2011

Friday, March 04, 2011

Thursday, February 17, 2011

Monday, November 15, 2010

Tuesday, November 09, 2010

forgatas Silverlight-ban

Az volt a feladat, hogy egy videot kellett 90 fokkal elforgatva megjeleniteni Silverlight-ban.

Erre van a PlaneProjection (msdn) ami 3D-ben tud forgatni, de nekunk eleg volt a RotationZ.

Tovabbi peldak:

Thursday, September 09, 2010

David Mendez: Start, Stop, and Restart Windows Services from Mac OS X

Innen.

Mac OS X includes Samba support by default, and this is really handy if you’d like to remotely restart and monitor services running on a Windows machine.

To list services running on the Windows machine, use this command:
net rpc service list -I IPADDRESS -U USERNAME%PASSWORD
A practical example would be:
net rpc service list -I 192.168.0.115 -U Windows%myPassword

After identifying the service you want to restart, you issue the following command to stop the service:
net rpc service stop SERVICENAME -I IPADDRESS -U USERNAME%PASSWORD

Then you can restart (or start) the service by using the following command:
net rpc service start SERVICENAME -I IPADDRESS -U USERNAME%PASSWORD

This is tip that I found on Lifehacker that was aimed at Linux users, but considering Mac OS X has a unix underbelly equipped with samba the command works just the same on a Mac.