I have a very strange problem with my problem on android 2.3.3 - I try to compile a basic fragment shader, but the compiler gives back a 0 as compileStatus.

Here is my shader compile snippet:

    if (fragmentShaderHandle != 0) {

        // Pass in the shader source.
        GLES20.glShaderSource(fragmentShaderHandle, fragmentShader);

        // Compile the shader.
        GLES20.glCompileShader(fragmentShaderHandle);

        // Get the compilation status.
        final int[] compileStatus = new int[1];
        GLES20.glGetShaderiv(fragmentShaderHandle, GLES20.GL_COMPILE_STATUS, compileStatus, 0);

        // If the compilation failed, delete the shader.
        if (compileStatus[0] == 0) {

            ErrorLog = GLES20.glGetShaderInfoLog(fragmentShaderHandle);

            GLES20.glDeleteShader(fragmentShaderHandle); 
            fragmentShaderHandle = 0;
        }           
    }

    if (fragmentShaderHandle == 0) {

        throw new RuntimeException("Error creating fragment shader. Error: " + ErrorLog);
    }

The strangest thing, that the glGetShaderInfoLog gives back an empty string as an error - I dont get any information, other then "Error creating fragment shader." which is my error message. If I skip that line, then the program binding will give an error, as the fragment shader is not existing.

I tried every shader (if there is the error) but even the simplest shader dont run (simplest shader: void main { gl_FragmentColor = vec4(1.0f, 1.0f, 1.0f, 1.0f) } this give the same error without any error message).

But: this code will run flawlesly on android 4.0 (my friend tried it, and its work in the emulator as well). I asked some other friend with android 2.3 - but everyone got the same error with no error message.

The telephone support OpenGL 2.0 ES - if I dont load shader, just clear the screen, it works just fine.

Anybody have any idea where should I start looking? Without error message, its pretty hard to hunt down where I messed up :|

Thank you!

No matter what type of mobile (multi-device) application I create in Delphi/C++ Builder XE6/7 and try to test it using Android emulator my application never starts and always crashes. This is happening even if my mobile application is totally empty (blank).

enter image description here

I always get something like this. What is causing this and how to fix it?

Additional emulator info: Android emulator platform: 4.4 API level: 19 CPU: ARM Using host GPU

Also, this is happening even if I use my mobile device connected to PC, so I'm at a total loss here.

I am making an app that creates a listview of authors and and when the user clicks an author I need to create an intent with another listview of that authors titles.

I cant seem to figure out how to make the new listview

This is main

setListAdapter(ArrayAdapter.createFromResource(getApplicationContext(),
                R.array.gutenberg_authors, R.layout.list_item));
     getListView().setOnItemClickListener(new OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> parent, View view,
                    int position, long id) {
                String author = mGutenbergAuthors[position];
                Intent showContent = new Intent(getApplicationContext(),
                        MainActivity.class);
                showContent.setData(Uri.parse(author));
                startActivity(showContent);

            }
        });

this is the xml of listView

 <?xml version="1.0" encoding="utf-8"?><TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="24dp"
android:padding="6dp" />

the authors and titles are in xml string arrays

Right now it just crashes when I click on an author

One of the authors in authors.xml

 <array name="andersens_titles">
    <item>The Emperor\'s New Clothes</item>
    <item>The Swineherd</item>
    <item>The Snow Queen</item>
    <item>The Leap-Frog</item>
    <item>The Bell</item>
    <item>The Old House</item>
    <item>The Happy Family</item>
    <item>The Story of a Mother</item>
    <item>The Dream of Little Tuk</item>
    <item>The Naughty Boy</item>
</array>

<array name="andersens_urls">
    <item>http://www.gutenberg.org/files/1597/1597-h/1597-h.htm#link2H_4_0001</item>
    <item>http://www.gutenberg.org/files/1597/1597-h/1597-h.htm#link2H_4_0002</item>
    <item>http://www.gutenberg.org/files/1597/1597-h/1597-h.htm#link2H_4_0006</item>
    <item>http://www.gutenberg.org/files/1597/1597-h/1597-h.htm#link2H_4_0007</item>
    <item>http://www.gutenberg.org/files/1597/1597-h/1597-h.htm#link2H_4_0009</item>
    <item>http://www.gutenberg.org/files/1597/1597-h/1597-h.htm#link2H_4_0010</item>
    <item>http://www.gutenberg.org/files/1597/1597-h/1597-h.htm#link2H_4_0011</item>
    <item>http://www.gutenberg.org/files/1597/1597-h/1597-h.htm#link2H_4_0012</item>
    <item>http://www.gutenberg.org/files/1597/1597-h/1597-h.htm#link2H_4_0016</item>
    <item>http://www.gutenberg.org/files/1597/1597-h/1597-h.htm#link2H_4_0017</item>
</array>

list of author names in gutenberg_authors

<?xml version="1.0" encoding="utf-8"?><resources>
  <string-array name="gutenberg_authors">
    <item>Hans Christian Andersen</item>
    <item>Mark Twain</item>
    <item>Rafael Sabatini</item>
    <item>Charles Dickens</item>
    <item>Guy de Maupassant</item>
    <item>Victor Hugo</item>
    <item>Leo Tolstoy</item>
    <item>Rudyard Kipling</item>
    <item>Rabindranath Tagore</item>
    <item>William Shakespeare</item>
</string-array>

Logcat

My application consists of a mobile Android client and a server backend. The backend has a database which can be accessed through a REST interface. I have no direct control over the backend since it belongs to the customer; I am developing the mobile client. The client's task is to display data records fetched from the server.

URLs for the different relations on the backend look like backend.com/data/mouse, backend.com/data/cat and backend.com/data/dog. In total the are 10 relations which have nothing in common and are pretty complex.

The client pulls data from the server with the help of Android services. For each relation exists an android.app.Service: MouseService, CatService and DogService. I use services because REST request should happen asynchronously.

The client has different views which display data records. One of them displays records from different relations. For example when the user accesses the MouseCatDogView, which is an android.app.Fragment, three Intents are created in the onResume() method; they target the corresponding services to get a couple of Mouse, Cat and Dog data records. The services get the Intents, send REST requests, wait for responses and broadcast new Intents which contain the response data records. The MouseCatDogView receives the response Intents and starts visualizing the extracted data as text.

To achieve a good user experience, requests and their responses are being cached so the MouseCatDogView can display data when there is no connection to the backend. Caching happens at service level. Requests are always answered with cached data and later updated with the latest data from the server.


Everything works fine except this little annoyance: The application stutters or jerks between opening the MouseCatDogView and the visualization of the data records as simple text.

I think the culprit is the communication through Intents. When there is no network connection, data records are pulled from the cache and there are still stutters. Intents seem to be time-consuming enough to slow the user interface down.

What are strategies to speed up the Intent mechanism? Is there a whole different strategy like accessing a cache directly, not through Intents, which takes care of fetching data in the background by itself?

What would you do?

I am currently a student taking a Mobile Device Applications development class and am getting stuck on my final project, an Address Book style app. I have used the example from our book (Dietel's Android for Programmers An App-Driver Approach, Volume 1, Second Edition) as the basis and have been editing code from there. The biggest thing I want to change/enable is to allow the user to select different fields within the contact (address, email, etc) and pass an Intent that will open Maps when address is selected, eMail when email is selected and so on. Where I am lost is where to place my listener and declare it. Our book and subsequent searches are not really clearing this up at all. I understand the onItemClick call, but am not sure where to place it, within MainActivity.java or the DetailsFragment.java, which is all the code to handle anything that happens when the contact is open and displayed. I feel like I can put it all within the DetailsFragment.java but have a nagging suspicion that I am missing something. I have not had the time to edit and test this yet as I am actually heading out for work in a minute but I thought I could maybe get a better understanding or maybe even better links to read to learn from as my Google search doesnt seem to address what I am looking for. Also, not sure if it matters or not, but I am not using a ListView at all and everything I find tries to force a ListView use. Thank you guys for your help/consideration and time.

I have one class Days

public class Days implements Serializable {
    private String id;
    private List<Hours> hours;
    //getters and setters
}

And a class Hours

public class Hours implements Serializable{
    private String id;
    private String comments;
    //getters and setters
}

I also have an activity with a ExpandableList that shows days as groups and hours as children. When I click on a specific hour, I pass the object hours to edit on another activity.

public class DaysListActivity extends ExpandableListActivity
            implements OnChildClickListener
{
    //Other methods
    @Override
    public boolean onChildClick(parameters...)
    {
        Intent i = new Intent(getApplicationContext(),HourActivity.class);
        i.putExtra("hourClicked",day.getHour(idHourClicked));
        startActivity(i);
    }
}

In HourActivity.class

public class HourActivity extends Activity{
    @Override
    public void onCreate(Bundle savedInstance)
    {
        ...
        Intent i = getIntent();
        Hour hour = (Hour) i.getSerializableExtra("hourClicked");
        updateHour(hour);
        ....
    }

    public void updateHour(Hour hour)
    {
        hour.setComment("Hellow world");
        Toast toast = Toast.makeText(getApplicationContext(), hour.getComment(), Toast.LENGHT_SHORT);
        toast.show();
    }    

}

Everything goes fine, the toast shows me "Hello world". But when i came back to DayListActivity, the hour that i've clicked and updated keeps the same value, it doesn't refresh. Wrost, if I click on the same hour again, i'ts like it was never updated to "Hello world"

I've already tried notifyDataSetChanged() on adapter and invalidateViews() on ExpandableListView. Which step am I missing?

I have a problem with adding the fragment transactions to the back stack. I have a Main activity in which I populate my layout with a Menu Fragment:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    getFragmentManager().beginTransaction().add(R.id.frag_container, new MainMenuFragment()).commit();
}

Then, inside the MainMenuFragment, the user chooses some option which results in replacing the menu fragment with some other fragment:

@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    FragmentTransaction trans = manager.beginTransaction();
    if (position == 0){
        trans.replace(R.id.frag_container, new BasicSettingsFragment());
        trans.addToBackStack(null);
        trans.commit();
    }
}

For what i understand, this should make it so that when the user presses back button on their device, they will be brought back to the menu fragment, but instead this quits the app. What am i doing wrong?

My app is depends on PDF files which I download it from URL and unzip it, which works fine.
but it re-download the file.zip every time I open it even if the file is downloaded and existed.
the file size is too big so it make much trouble and hard to use.

I hope you can help
thanks alot

public class MainActivity extends Activity {


 String Url="www....zip";
 String unzipLocation = Environment.getExternalStorageDirectory() + "/unzipFolder/";
 String StorezipFileLocation =Environment.getExternalStorageDirectory() + "/DownloadedZip"; 
 String DirectoryName=Environment.getExternalStorageDirectory() + "/unzipFolder/files/";

 @Override
 protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    DownloadZipfile mew = new DownloadZipfile();
    mew.execute(Url);



class DownloadZipfile extends AsyncTask<String, String, String>
{
     String result ="";
     @Override
     protected void onPreExecute()
     {

      super.onPreExecute();
      mProgressDialog = new ProgressDialog(MainActivity.this);
      mProgressDialog.setMessage("Downloading ... ");
      mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
      mProgressDialog.setCancelable(false);
      mProgressDialog.show();
     }

     @Override
     protected String doInBackground(String... aurl)
     {
      int count;

      try
      {
           URL url = new URL(aurl[0]);
           URLConnection conexion = url.openConnection();
           conexion.connect();
           int lenghtOfFile = conexion.getContentLength();
           InputStream input = new BufferedInputStream(url.openStream());

           OutputStream output = new FileOutputStream(StorezipFileLocation);

           byte data[] = new byte[1024];
           long total = 0;

           while ((count = input.read(data)) != -1)
               {
                total += count;
                publishProgress(""+(int)((total*100)/lenghtOfFile));
                output.write(data, 0, count);
               }
           output.close();
           input.close();
           result = "true";
      } 

      catch (Exception e) {

       result = "false";  }
      return null;

     }

     protected void onProgressUpdate(String... progress)
     {
      Log.d("ANDRO_ASYNC",progress[0]);
      mProgressDialog.setProgress(Integer.parseInt(progress[0]));
     }

     @Override
     protected void onPostExecute(String unused)
     {
      mProgressDialog.dismiss();
      if(result.equalsIgnoreCase("true"))
      {
       try
       {
        unzip();
       } catch (IOException e)
       {
        // TODO Auto-generated catch block
        e.printStackTrace();
       }
      }
      else
      {

      }
     }
    }

I have an issue with my onclicklistener in relation with my gridview. When I click the left or right side of the gridview it says I'm on the first fragment, however if I click in the middle of the gridview it says I'm on the second fragment? On the image I added if you click on the blue part it says its the first (0th) fragment and if you click anywhere on the green part it says second (1st) fragment. How can I solve this? Here's my code:

overviewGridView.setOnItemClickListener(new OnItemClickListener() {
//startoffset variable comes from the savedinstancestate bundle
    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
        Toast.makeText(getActivity(), "Tapped:" + position + "Page: " + startOffset, Toast.LENGTH_SHORT).show();
    }
});

Here's my grid layout:

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/overviewRelativeLayout"
    android:layout_width="match_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <android.support.v4.widget.SwipeRefreshLayout
    android:id="@+id/swipe_container"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <GridView
        android:id="@+id/overviewGridView"
        android:layout_width="match_parent"
        android:layout_height="fill_parent"
        android:layout_centerHorizontal="true"
        android:layout_centerInParent="true"
        android:layout_centerVertical="true"
        android:layout_marginLeft="30dp"
        android:layout_marginRight="30dp"
        android:horizontalSpacing="10dp"
        android:numColumns="4"
        android:paddingLeft="20dp"
        android:paddingRight="20dp"
        android:paddingTop="55dp"
        android:verticalSpacing="10dp" >

    </GridView>
        </android.support.v4.widget.SwipeRefreshLayout>

    <TextView
        android:id="@+id/refreshAppointmentsTextView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="8dp"
        android:textColor="@android:color/black"
        android:textSize="24sp"
        android:visibility="invisible" />
</RelativeLayout>

And my fragmentmanager:

public GridAdapter(FragmentManager fm) {
    super(fm);
}

@Override
public Fragment getItem(int itemPos) {
    Log.d("Fragment", "Created new fragment: " + itemPos);
    return GridFragment.newInstance(itemPos);
}

Image here: http://i.stack.imgur.com/PvFRX.jpg

I need to create a temporary file, fill it with some data and send the result to a function that accepts only std::istreams.

I tried using tmpfile() and it works for my first requirement - 'create a file and fill it with some data', but it returns a FILE* and there is no way to convert it (as far as I know) to std::streams.

Is there a C++ way of creating a temporary file? If this is not possible, how reliable is tmpnam to return a valid file name? Did anyone test this on Android or iOS?

EDIT: I don't want to copy the data to std::stringstream as a part of my test is reading the data from the disk.

Im trying to display the item name of the listview when its popupmenu is being clicked but i'm have trouble with it because it always show or returns "false" value. Any ideas how to solve this? thanks

   public void toast(View v){
        showPopupMenu(v);
    }
    private void showPopupMenu(View v){
        PopupMenu pop = new PopupMenu(CompanyActivity.this, v);
        pop.getMenuInflater().inflate(R.menu.menu,pop.getMenu());

        pop.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {

            @Override
            public boolean onMenuItemClick(MenuItem item) {
                if(item.getItemId() == R.id.view){
                    Toast.makeText(getApplicationContext(),item.getItemId(),Toast.LENGTH_SHORT)
                          .show();

                    return true;
                }

                return false;
            }
        });

        pop.show();
    }

Edited: I want to get the value of the list item in the listview being clicked but it shows the menu item that is being clicked.

public void toast(View v){
        showPopupMenu(v);
    }
    private void showPopupMenu(View v){
        PopupMenu pop = new PopupMenu(CompanyActivity.this, v);
        pop.getMenuInflater().inflate(R.menu.menu,pop.getMenu());

        pop.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {

            @Override
            public boolean onMenuItemClick(MenuItem item) {
                Toast.makeText(CompanyActivity.this,"text: "+item.getTitle(),Toast.LENGTH_SHORT).show();

                return true;
                }
            });
        pop.show();
    }

I am trying to run the packetspammer application on an Android nexus-7 wifi only tablet (code name: grouper). I downloaded the libpcap library and was able to generate the static library (libpcap.a). However, when I try to build the packetspammer app using NDK-build, I keep getting linker errors.

My folder structure looks like this:

packetspammer
|
jni
  |
  packetspammer source files
  Android.mk file that links in libpcap and builds the packetspammer binary
  <Directory>platform_external_libpcap 
       |
       libpcap.a file

Here is my android.mk file:

#Links the libpcap library
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE    := platform_external_libpcap/libpcap
LOCAL_SRC_FILES := platform_external_libpcap/libpcap.a
LOCAL_EXPORT_C_INCLUDES := platform_external_libpcap
include $(PREBUILT_STATIC_LIBRARY)

#Builds packetspammer app
include $(call all-subdir-makefiles)
include $(CLEAR_VARS)

LOCAL_MODULE    := packetspammer
LOCAL_SRC_FILES := radiotap.c packetspammer.c 
LOCAL_STATIC_LIBRARIES  := platform_external_libpcap/libpcap.a
LOCAL_C_INCLUDES := ~/android/android-ndk-r10b/platforms/android-L/arch-arm/usr/include \
                ~/packetspammer/jni/platform_external_libpcap

TARGET_ARCH     := arm

include $(BUILD_SHARED_LIBRARY)

These are the error messages I get:

error: undefined reference to 'pcap_open_live'
error: undefined reference to 'pcap_datalink'
error: undefined reference to 'pcap_compile'
error: undefined reference to 'pcap_geterr'
error: undefined reference to 'pcap_setfilter'
error: undefined reference to 'pcap_geterr'
error: undefined reference to 'pcap_freecode'
error: undefined reference to 'pcap_setnonblock'
error: undefined reference to 'pcap_next_ex'
error: undefined reference to 'pcap_inject'

Can you tell me what is wrong with either the Android.mk file or with the process I follow. I looked at the NDK programmer's guide and followed the section "Building/Standalone toolchain" as well as "Building/Android.mk". I get the same linker error even with the standalone toolchain.

I found many posts that helped me solve several of my errors before I got stuck here. Here are the links to those:

undefined reference error while statically linking;

linking third party libs;

trouble linking static libraries;

using a pre-compiled static library;

libpcap for android;

compile libpcap using android ndk

porting JNetPcap

I have an activity that gets a string through intent extras:

i.putExtra("static_image", theUri.toString());
startActivity(i);

in my activity:

Uri imageUri = Uri.parse(intent.getStringExtra("static_image");

It works, but if I don't close the app and I open that activity again with a different uri, the intent gives me the old one...

I think the intent is being reused. How can I reset the activity or force the activity to use the new intent?

thanks

There has to be a better way to do this but everything I've tried fails. Maybe I have to programtically create the textViews, I'm not sure.

I have this:

if (totalCount[0] > 0) {
    b1Pct = df.format((totalMs[0] / (float) totalTestMs) * 100);
    b1 = df.format((totalBits[0] / totalCount[0]) / 1000000);
}
if (totalCount[1] > 0) {
    b2Pct = df.format((totalMs[1] / (float) totalTestMs) * 100);
    b2 = df.format((totalBits[1] / totalCount[1]) / 1000000);
}
if (totalCount[2] > 0) {
    b3Pct = df.format((totalMs[2] / (float) totalTestMs) * 100);
    b3 = df.format((totalBits[2] / totalCount[2]) / 1000000);
}

As you can see I have need of a loop to cut this code down, it actually goes for another 6 entries. I'd like to do something like this but it doesn't work how I'd hoped:

for (var i=0; i < totalCount.length; i++) {

var count = i+1;

    if (totalCount[i] > 0) {
        "b"+count+"Pct" = df.format((totalMs[i] / (float) totalTestMs) * 100);
        "b"+count = df.format((totalBits[i] / totalCount[i]) / 1000000);
        "Bucket"+count.setText(b+count); "Bucket"+count+"pct".setText("b"+count+"Pct");
    }
}

Obviously that doesn't work. Any ideas would be greatly appreciated.

The problem is occurring in Eclipse

Version: Kepler Service Release 2
Build id: 20140224-0627

With ADT version 23.0.3.1327240, and attempting build with API level 14.

The problem is with eclipse only occasionally throwing an error with layout XML files. The code that should be throwing an error all the time is the first line inside the text view here:

<TextView
    android:id="@+id_crm_activity_list/tvSignoff"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:text="@string/signoff"
    android:textStyle="bold" >
</TextView>

It is not correct to declare an id like @+id_blah/blah it must be @+id/blah. When I start eclipse the error throws correctly and I am restricted from building and running the project, but if I clean the project all of a sudden the error is gone and I can build/run the project without any errors whatsoever.

Normally I would just change the code to correctly declare the new id, but it is not my code and I don't really have the time or need to go through all the files and try to fix them (there are many layouts like this).

I can bring the error back by changing anything in the offending layout, even just white-space, and then saving the file.

I can get rid of the error just by cleaning the project at any time.

The fact that it isn't working correctly is actually good for me because I can change the code I need and still test the changes without worrying about the errors in the code I am not touching, but it is worrying me as this does not seem like well defined behavior.

The last point of note is that I am accessing the project with the eclipse perforce plugin version 2013.1.788968

i want to check some url at 9:00 a.m everyday.But how can i do this? I did check some topic and article about AlarmManager and IntentService but i can't get together for my application , is there any example code or something ?Thank you..

I have issue with constrain using custom UITabBarController.

My solution to create custom tab bar it is find UITabBar in class that is subclass of UITabBarController and hide it. Instead of tab bar I use then UIView customised in the XIB.

In -viewWillAppear I hide my tab bar

- (void)hideExistingTabBar
{
    for (UIView *view in self.view.subviews)
    {
        if ([view isKindOfClass:[UITabBar class]])
        {
            view.hidden = YES;
            break;
        }
    }
}

Everything works perfect but not a constrain of table height. So in UIViewController that is attached as a first tab of my custom tab bar I have table that have constraint like on image below:

enter image description here

But as I have hide UITabBar in -viewWillAppear method it seems affect on the constraint immediately after removing. And after hiding seems the extremal bottom point is not tab bar origin y point but point of the bottom of the screen. And seems it is correct.

But my question is how can bind the constrain to my new custom view that is replace tab bar.

I found this answer. And seems it can be a solution, especially adding contentInset but it just solved a visual part. So the last cell right now is displayed when we scroll to the down, but the height of table view still the same.

everyone i want to send integer value using slider via Bluetooth to arduino . so please help in making that blocks.

I have a json code in this link: here

I'm trying to parse it by that code:

  JSONObject jsonObj;
        try {
            jsonObj = new JSONObject(json.substring(json.indexOf("{"), json.lastIndexOf("}") + 1));
            System.out.println("jsonObj: "+jsonObj);

            jArray = new JSONArray();
            jArray.put(jsonObj);

        } catch (JSONException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }

But it gives just the first element. How to get all elements of the JSON?

final Dialog dialog = new Dialog(MainScreenActivity.this);

dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);

dialog.setContentView(R.layout.activity_ana_ekran_dialog);
dialog.setCanceledOnTouchOutside(true);

Display display = getWindow().getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
int width = size.x;
WindowManager.LayoutParams params = getWindow().getAttributes();
params.width = width * 90 / 100;
dialog.getWindow().setAttributes(params);

dialog.show();

This code is in onOptionsItemSelected section when i press action bar button my custome dialog doesn't appear.

My custom dialog doesn't appear when i set it's width?

when creating a new android application project..a by default activity should be created in my "src" folder .. but when i created new project there is no any default activity... i have chose "blank activity " too.. what can i do for this ?? and its compulsory that a by default activity must be created according to this official site: http://developer.android.com/training/basics/firstapp/building-ui.html please help