Tuesday, 24 September 2013

Calling other App from one App

package com.example.testintaller;

import android.app.Activity;

import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class MainActivity extends Activity {

    private Button btn;

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

        btn = (Button) findViewById(R.id.button1);

        btn.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub

               

                   
                     Intent intent = new Intent(Intent.ACTION_MAIN);
                     intent.setClassName("package", "package.classname");
                     intent.putExtra("name", "xxx");
                     intent.putExtra("password", "yyyy");
                    startActivity(intent);
                   
           

            }
        });

    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

}


Note : Activity class of ther App which you are calling should be exported i,e in manifest we should give as android:exported = "true"

Tuesday, 3 September 2013

CustomView (accessing attrs.xml)

package com.example.customviewsecondexampkle;

import android.os.Bundle;

import android.app.Activity;
import android.view.Menu;

public class MainActivity extends Activity {

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

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

}


package com.example.customviewsecondexampkle;

import android.content.Context;

import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.widget.TextView;

public class ViewV extends TextView
{
    public ViewV(Context ctx, AttributeSet attrs)
    {
        super(ctx, attrs);

        TypedArray array = ctx.obtainStyledAttributes(attrs, R.styleable.CustomAttrs);
        String text = array.getString(R.styleable.CustomAttrs_xattr);
       
        if(text != null)
        {
          
        }
        array.recycle();
    }

}

activity_main.xml

<LinearLayout
       xmlns:android="http://schemas.android.com/apk/res/android"
       xmlns:app="http://schemas.android.com/apk/res/com.example.customviewsecondexampkle"
      android:orientation="vertical"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent" >

    <com.example.customviewsecondexampkle.ViewV
           android:layout_width="fill_parent"
           android:layout_height="wrap_content"
           app:xattr="testing"  />

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="TextView" />

</LinearLayout>

attrs.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <declare-styleable name="CustomAttrs">
        <attr name="xattr" format="string" />
         <attr name="labelColor" format="color"/>
   
    </declare-styleable>
</resources>

Pass a HashMap from Angular Client to Spring boot API

This example is for the case where fileData is very huge and in json format   let map = new Map<string, string>()      map.set(this.ge...