Note that there are some explanatory texts on larger screens.

plurals
  1. POstartActivity method doesn't launch the new activity in real device
    primarykey
    data
    text
    <p>I am a beginner in Android. I am trying to start a new activity via an intent inside an onclick event. This works fine in emulator. But when I try it in a real device it doesn't work and the application goes to the main screen again. No errors are shown in the logcat. </p> <p>This is where I call the <code>startActivity</code> method. </p> <pre><code>relativeAbout.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub try { Class OurClass = Class .forName("com.wad.tourismguide.AboutCity"); Intent newIntent = new Intent(getApplicationContext(), OurClass); newIntent.putExtra("name", name); newIntent.putExtra("detail", detail); newIntent.putExtra("image", main); startActivity(newIntent); System.out.println("intent starting"); } catch (ClassNotFoundException e) { // TODO: handle exception e.printStackTrace(); } } }); </code></pre> <p>The new activity is shown below. </p> <pre><code> public class AboutCity extends Activity { TextView cityName; ImageView image; TextView detailText; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.aboutcity); cityName = (TextView)findViewById(R.id.tvDetailCityName); image = (ImageView)findViewById(R.id.ivDetailImage); detailText = (TextView)findViewById(R.id.tvDetailText); String name = getIntent().getStringExtra("name"); System.out.println("city name"+ name); String detail = getIntent().getStringExtra("detail"); System.out.println("city detail"+ detail); Bitmap b= (Bitmap)getIntent().getParcelableExtra("image"); System.out.println(detail); cityName.setText(name); detailText.setText(detail); image.setImageBitmap(b); } } </code></pre> <p>As I explained earlier, this works fine in the emulator. But it doesn't work in the real device. I can't find where I am going wrong. Can someone please help me with this?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload