How-To: Display Emulator in Landscape (Sideways) View?

by JLMG » Thu, 12 Mar 2009 06:41:06 GMT


Sponsored Links
 I was over at db4o and they had a demo with the emulator displayed in
landscape (sideways) mode.

How do you do that?

I'm developing and app that needs the keyboard exposed.

Thanks!

JLMG
--~--~---------~--~----~------------~-------~--~----~



How-To: Display Emulator in Landscape (Sideways) View?

by Mark Murphy » Thu, 12 Mar 2009 06:41:50 GMT


 


<Ctrl>-<F12> toggles you between portrait and landscape modes in the
emulator.

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com 
Android Training in Sweden --  http://www.sotrium.com/training.php 

--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Other Threads

1. Custom Service Permission

Hi,

I am unable to access my custom service after setting permission.
03-08 16:38:15.730: WARN/ActivityManager(53): Permission Denial:
Accessing service ComponentInfo{com.kilic.service/
com.kilic.service.AdditionService} from pid=235, uid=10026 requires
com.kilic.service.permission.MY_FIRST_SERVICE
03-08 16:41:53.141: INFO/System.out(314): Not allowed to bind to
service Intent { act=com.kilic.service.IAdditionService }

If I remove the permission everything works fine. Is there anything
special I need to do in the client manifest other than <uses-
permission> ?

Here is my code snippet for the service:

package com.kilic.service;

import android.app.Service;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.IBinder;
import android.util.Log;

/**
 * This class exposes the remote service to the client
 */
public class AdditionService extends Service {
  private static final String TAG = "AdditionService";


  private final IAdditionService.Stub binder=new
IAdditionService.Stub() {
                public int add(int value1, int value2) {
              Log.d(TAG, String.format("AdditionService.add(%d,
%d)",value1, value2));
                        return toppla(value1, value2);
                }
  };

  @Override
  public void onCreate() {
    super.onCreate();
    Log.d(TAG, "onCreate()");
  }

  @Override
  public IBinder onBind(Intent intent)
  {
          //if(intent.getAction() != null &&
intent.getAction().equals(ACTION_SERVICE_MANAGEMENT)) {
                  // check permission
          System.out.println("intent.getAction() = " + intent.getAction());
 
if(this.checkCallingPermission("com.kilic.service.permission.MY_FIRST_SERVICE")
== PackageManager.PERMISSION_DENIED) {
//                                      Log.d(TAG, "Checked for permission: " + 
PERMISSION_MANAGEMENT
+ "\nresult: " + checkCallingPermission(PERMISSION_MANAGEMENT));
                                                  Log.d(TAG, "Checked for 
permission: \nresult: " +
checkCallingPermission("com.kilic.service.permission.MY_FIRST_SERVICE"));
                          throw new SecurityException();
                }
                  // return management binder
                //return (binder);
          //}

          Log.d(TAG, "onBind finished");
          // call was not local so return public binder
          return (binder);
  }

  /*
  @Override
  public IBinder onBind(Intent intent) {

    return (binder);

  } */

/**
 * Implementation of the add() method
 */
  private int toppla(int value1, int value2) {
      Log.d(TAG, String.format("AdditionService.toppla(%d,
%d)",value1, value2));
      return value1 + value2;
  }


  @Override
  public void onDestroy() {
    super.onDestroy();
    Log.d(TAG, "onDestroy()");
  }
}
------------------------------------------------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.kilic.service"
      android:versionCode="1"
      android:versionName="1.0">
    <application android:icon="@drawable/icon" android:label="@string/
app_name">
                <service android:name=".AdditionService"
 
android:permission="com.kilic.service.permission.MY_FIRST_SERVICE"
                                 android:process=":remote"
                                 android:enabled="true"
                                 android:exported="true">

                        <intent-filter>
                                <action 
android:name="com.kilic.service.IAdditionService" />
                        </intent-filter>
                </service>
    </application>
    <uses-sdk android:minSdkVersion="4" />
<uses-permission
android:name="com.kilic.service.permission.MY_FIRST_SERVICE"></uses-
permission>

</manifest>

===============================================
And this is the client code:

package com.kilic.service.client;

import com.kilic.service.client.R;
import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.IBinder;
import android.os.RemoteException;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import com.kilic.service.IAdditionService;


public class AIDLDemo extends Activity {
  private static final String TAG = "AIDLDemo";
  private IAdditionService service= null;
  //private AdditionServiceConnection connection;

  /**
   * This class represents the actual service connection. It casts the
bound
   * stub implementation of the service to the AIDL interface.
   */
  private ServiceConnection  svcConn  = new ServiceConnection() {

            public void onServiceConnected(ComponentName name, IBinder
boundService) {
              service = IAdditionService.Stub.asInterface(boundService);
              Log.d(AIDLDemo.TAG, "onServiceConnected() connected");
              Toast.makeText(AIDLDemo.this, "Service connected",
Toast.LENGTH_LONG)
                  .show();
            }

            public void onServiceDisconnected(ComponentName name) {
              service = null;
              Log.d(AIDLDemo.TAG, "onServiceDisconnected() disconnected");
              Toast.makeText(AIDLDemo.this, "Service connected",
Toast.LENGTH_LONG)
                  .show();
            }
  };


  /** Unbinds this activity from the service. */
  private void releaseService() {
    unbindService(svcConn);
    svcConn = null;
    Log.d(TAG, "releaseService() unbound.");
  }


  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    // Setup the UI
    Button buttonCalc = (Button) findViewById(R.id.buttonCalc);

    buttonCalc.setOnClickListener(new OnClickListener() {
      TextView result = (TextView) findViewById(R.id.result);
      EditText value1 = (EditText) findViewById(R.id.value1);
      EditText value2 = (EditText) findViewById(R.id.value2);

      public void onClick(View v) {
        int v1, v2, res = -1;
        v1 = Integer.parseInt(value1.getText().toString());
        v2 = Integer.parseInt(value2.getText().toString());

        try {
          res = service.add(v1, v2);
        } catch (RemoteException e) {
          Log.d(AIDLDemo.TAG, "onClick failed with: " + e);
          e.printStackTrace();
        }
        result.setText(new Integer(res).toString());
      }
    });
    /** Binds this activity to the service. */
    try {
        boolean ret = bindService(new
Intent(IAdditionService.class.getName()), svcConn,
Context.BIND_AUTO_CREATE);
    }
    catch (SecurityException se) {
        System.out.println(se.getMessage());
    }

  }

  /** Called when the activity is about to be destroyed. */
  @Override
  protected void onDestroy() {
        super.onDestroy();
    releaseService();
  }

}
-----------------------------------------------------------------------------------------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.kilic.service.client"
      android:versionCode="1"
      android:versionName="1.0">
    <application android:icon="@drawable/icon" android:label="@string/
app_name">
        <activity android:name=".AIDLDemo"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category
android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

    </application>
    <uses-sdk android:minSdkVersion="5" />
<uses-permission
android:name="com.kilic.service.permission.MY_FIRST_SERVICE"></uses-
permission>

</manifest>

================================================================================



I would appreciate any help.

Thanks,
 - Kilic

-- 

2. onSingleTapConfirmed and different screen sizes

I am developing a game in which there are a couple of on-screen
buttons
the user can press to do different things. These work by responding
to
onSingleTapConfirmed, and checking if the getX and getY of the event
are
within the coordinates of the buttons.

However, the getX and getY coordinates are different when the game is
played on other screen sizes than the game was developed on.

How is the best way to deal with that? Of course I could call
getWidth
and getHeight and do lots of if's on them, but it would be better to
have a more general way of doing it.

Does anyone know of such a way?

The game is implemented on a GLSurfaceView.

Thanks.

-- 

3. Problem in encoding image

4. Custom View orientation change

5. onCellLocationChanged and updateNetworkNameExtension showing up in Log files. Where do these come from? and can I make them stop?

6. facing issue with sound driver(TLV320AIC33)

7. ext2/3/4 file system support in emulator