Hey Guys,

Is it possible to create another classes object in a class in android.

*I am tryin to do the following:*

/*
 * Copyright (C) 2009 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.example.hellojni;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;


public class HelloJni extends Activity
{
    private samplefile obj123;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        obj123.set123(/*"hello yaar"*/);
        /* Create a TextView and set its content.
         * the text is retrieved by calling a native
         * function.
         */
        TextView  tv = new TextView(this);
        //tv.setText( stringFromJNI() );
        tv.setText( obj123.get123() );
        setContentView(tv);
    }

    /* A native method that is implemented by the
     * 'hello-jni' native library, which is packaged
     * with this application.
     */
    public native String  stringFromJNI();

    /* This is another native method declaration that is *not*
     * implemented by 'hello-jni'. This is simply to show that
     * you can declare as many native methods in your Java code
     * as you want, their implementation is searched in the
     * currently loaded native libraries only the first time
     * you call them.
     *
     * Trying to call this function will result in a
     * java.lang.UnsatisfiedLinkError exception !
     */
    public native String  unimplementedStringFromJNI();

    /* this is used to load the 'hello-jni' library on application
     * startup. The library has already been unpacked into
     * /data/data/com.example.HelloJni/lib/libhello-jni.so at
     * installation time by the package manager.
     */
    static {
        System.loadLibrary("hello-jni");
    }
}


*And, samplefile.java(which is in the same package i.e com.example.hellojni)
looks like:*

package com.example.hellojni;

public class samplefile{
    private String abc;
    public samplefile()
    {
        abc=null;
    }
    public void set123(/*String fgh*/)
    {
        abc="fgh";
    }
    public String get123()
    {
        return abc;
    }
}


But this code would just not run and gives an exception of the group:

W/dalvikvm(  950): threadid=3: thread exiting with uncaught exception
(group=0x4001b180)

Why is this happening? This is something very basic which I am trying to do.
And I think I am making some very silly mistake. Do I need to make any
changes in AndroidManifest.xml for the class samplefile and its file
samplefile.java.

What am I missing? Please guide me guys.

Thanks,

Abhyudai

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to