Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4362: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4364: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4365: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4366: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
anddev.org • View topic - Explicit Intent For Result Problem

Explicit Intent For Result Problem

Put your problem here if it does not fit any of the other categories.

Explicit Intent For Result Problem

Postby grimx » Mon Dec 28, 2009 10:19 pm

What i'm tring to do is ParentActivity start SubActivity forResult on the push of the Open button
and thats where it force closes.
Help.


ParentActivity.java
Code: Select all
package com.grimx.ParentActivity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Button;
import android.widget.TextView;
import android.view.View;

public class ParentActivity extends Activity implements View.OnClickListener{
   private static final int SHOW_SUBACTIVITY = 1;
    Button open_btn;
    TextView textView;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
       
        textView = (TextView)findViewById(R.id.textView);
        open_btn = (Button)findViewById(R.id.open);
        open_btn.setOnClickListener(this);
    }

   @Override
   public void onClick(View v) {
      if(v.getId() == R.id.open) {
         textView.setText("Open Button Was Clicked");
         Intent my_intent = new Intent(ParentActivity.this, SubActivity.class);
         startActivityForResult(my_intent, SHOW_SUBACTIVITY);
         //startActivity(my_intent);
      }
   }
   
   

   protected void onActivityResult(int requestCode, int resultCode, Intent data) {
      
      super.onActivityResult(requestCode, resultCode, data);
      
      switch(requestCode) {
         case(SHOW_SUBACTIVITY):
         {
            if(resultCode == Activity.RESULT_OK) {
            String stuff = data.getDataString();
            textView.setText(stuff);
            }   
         }
         break;
         }
   }
}



SubActivity
Code: Select all
package com.grimx.ParentActivity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Button;
import android.widget.TextView;
import android.view.View;

public class SubActivity extends Activity implements View.OnClickListener{
   protected final int RETURN_CODE = 1;
   Button send_btn;
   TextView textView;
   
   public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.sub);
       
        textView = (TextView)findViewById(R.id.textView);
        send_btn = (Button)findViewById(R.id.send);
        send_btn.setOnCreateContextMenuListener(this);
       
    }

   @Override
   public void onClick(View v) {
      String data = null;
      
      if(v.getId() == R.id.send) {
         //data = (String)textView.getText();
         Intent myIntent = new Intent();
         myIntent.putExtra("data", textView.getText().toString());
         
         setResult(RETURN_CODE, myIntent);
         finish();
      }
   }

}


AndroidManifest.xml
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  
  2. <?xml version="1.0" encoding="utf-8"?>
  3.  
  4. <manifest xmlns:android="http://schemas.android.com/apk/res/android"
  5.  
  6.      package="com.grimx.ParentActivity"
  7.  
  8.      android:versionCode="1"
  9.  
  10.      android:versionName="1.0">
  11.  
  12.     <application android:icon="@drawable/icon" android:label="@string/app_name">
  13.  
  14.         <activity android:name=".ParentActivity"
  15.  
  16.                  android:label="@string/app_name">
  17.  
  18.             <intent-filter>
  19.  
  20.                 <action android:name="android.intent.action.MAIN" />
  21.  
  22.                 <category android:name="android.intent.category.LAUNCHER" />
  23.  
  24.             </intent-filter>
  25.  
  26.         </activity>
  27.  
  28.         <activity android:name=".SubActivity"
  29.  
  30.                         android:label="@string/sub_name">
  31.  
  32.         </activity>
  33.  
  34.     </application>
  35.  
  36.     <uses-sdk android:minSdkVersion="3" />
  37.  
  38.  
  39.  
  40. </manifest>
  41.  
  42.  
Parsed in 0.001 seconds, using GeSHi 1.0.8.4
grimx
Junior Developer
Junior Developer
 
Posts: 20
Joined: Sat Dec 05, 2009 12:47 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 9 guests