Tag: Android

Launch Your Android App Using Your Website URL

You have a website and an android application and you want it so that an android user will be redirected to the application once they open a link from their email. Good thing android have an easy way to do this using Intents and Intent filters.

The first step is to add an information in your applications AndroidManifest.xml to tell the system that you want to received an intent regarding opened links. Open your AndroidManifest and add the following under the activity that you want to receive the intent.

<activity
 android:name=".MainActivity">
 <intent-filter>
 <action android:name="android.intent.action.MAIN" />
 <category android:name="android.intent.category.LAUNCHER" />
 </intent-filter>
 <intent-filter>
 <action android:name="android.intent.action.VIEW" />
 <category android:name="android.intent.category.DEFAULT" />
 <category android:name="android.intent.category.BROWSABLE" />
 <data android:scheme="http" android:host="www.jamesbaltar.com"/>
 </intent-filter>
</activity>

What this does is tell android that your activity can handle and process links that was opened by users. Now everytime a user opens a link to www.jamesbaltar.com a popup window will appear showing a list of applications that can process the link this includes browsers installed, your application and some application that have also registered for this.

Continue reading

Android: Using An Adapter For Dynamic ListView

This a continuation of my Android: Using An Adapter For ListView post. So please read that first you if haven’t done yet. The projects files for this tutorial is also there.

Adding The Dynamic Functionality

To add the dynamic functionality for the ListView we will need to add 2 functions for adding and removing items in our class that implemented the BaseAdapter. For the function of adding strings:

public void addString( String val ) {
 m_data.add(val);
 notifyDataSetChanged();
}

Aside from just normally adding the string to our data container called m_data. We are also calling the notifyDataSetChanged(), this function will notify the View where are our Adapter is connected. For this instance we will notify the ListView that the underlying data has changed and it must refresh its display/content.

Removing items is also the same, we will remove it normally from the List and notify the ListView of the changes done on the data.

public boolean removeString( int location ) {
 if ( location >= m_data.size() ) {
 return false;
 }
 m_data.remove(location);
 notifyDataSetChanged();
 return true;
}

We also added the location of the item that we need to remove. The important part of these 2 function is the line where we call the notifyDataSetChanged() since without calling it your view will not refresh and show the changes you’ve done.

Android: Using An Adapter For ListView

Creating A Custom Adapter

To use an Adapter with a ListView you must first extends an Adapter.

 class MyAdapter extends BaseAdapter {

Create a List member for the data container.

List<String> m_data = ArrayList<String>();

m_data will contain all string items that you will want to be displayed in the ListView. So in our constructor we will populate m_data with the strings we want to be shown.

 public MyAdapter() {
 m_data.add("item 1");
 m_data.add("item 2");
 m_data.add("item 3");
 }

Continue reading

Compiling OGRE3D for Android

Update: 2015-02-18 – ndk version

You can now compile OGRE3D using NDK and the OGRE branch version 1.9. Ive followed the instruction in OGRE wiki for compiling for Android but got stuck several times in several areas and almost just give up. Im new to Android specially using the NDK and all of this just overwhelmed me. So this is a step by step guide Ive decided to make on how to compile OGRE for people that are like me, new to Android.

Requirements:

Continue reading

© 2024 James Baltar

Theme by Anders NorenUp ↑