[TIPS / TRICKS] Create Android App For Your Forum

Started by Hj Ahmad Rasyid Hj Ismail, August 24, 2014, 12:59:50 AM

Previous topic - Next topic

Hj Ahmad Rasyid Hj Ismail


-Captain Ghost-

Quote from: ahrasis on September 01, 2014, 02:54:00 AM
Quote from: -Captain Ghost- on August 31, 2014, 02:51:58 AM
Edit: Everything is working perfectly now
Nice to hear that Captain Ghost.
request: can a progress bar or loader be added to this.

Hj Ahmad Rasyid Hj Ismail

Possible. Will try to add that and cookies for the app soon.

Chalky

Thanks for the reply ahrasis.  I haven't a clue what I'm doing  :P so I followed the steps exactly and to the letter.  What I did do was make tweaks in those initial 4 "next"s in Getting Started to add my own icon.  I have all the files you specified and I did not touch any others.  I too am using Eclipse.

I think I'm going to scrap it and start again in case I did something stupid in those early steps...

Hj Ahmad Rasyid Hj Ismail

#24
Updated the OP. Added support for cookies and progress bar. App should now remember cookies until they are expired and will have a progress bar on the top while the page is loading.

Edited: Only ForumActivity.java (with proper comments for easy understanding) and forum.xml files are updated. Attachments and other files' code are not updated yet as nothing is changed.

Akshtsaklani7

#25
hey, i'm having some errors







Please help..

Edit:- Google is my best friend. Problem Solved..

Hj Ahmad Rasyid Hj Ismail

Yeah. That should be easy to fix. Both pictures shows forum.xml and main.xml not named yet or have different name or not properly spelled.  The same with webView and buttonUrl. ;)

Bob Marley

Hello.  8)

Could the author of this topic help me with this error that i got (On picture)

Thanks


Hj Ahmad Rasyid Hj Ismail

Not really. I can only help if you can tell me what you did, step by step until you get that error. You need to do exactly the same as what is stated in the OP.

Oiled

Thanks for this guide. I've created a new project in Android Studio, used the files you attached and tried to build the app, I get these errors. Any ideas please?


Hj Ahmad Rasyid Hj Ismail

That is the string where you defined things. I did attach the strings.xml in the OP. One more thing, do not copy the file but copy its contents to your files and change accordingly once you have copied it.

Oiled

Thanks. I started from scratch and followed these instructions instead: hxxp:developer.chrome.com/multidevice/webview/gettingstarted [nonactive]

Worked perfectly. Now have an app complete with splash screen.

Hj Ahmad Rasyid Hj Ismail


hitsme

#33
Quote2. You will be needing JAVA for it to work. I won't teach you this. Please search and read.
you can download java here
Control Panel\System and Security\System advanced system settings > advanced > environment variables > system variables > new >variable name = JAVA_HOME value = user\jdk etc




  • I found that "<!DOCTYPE project>" was giving me problems.

  • In the AndroidManifest.xml
    <application
            android:allowBackup="true"
            android:icon="@drawable/ic_launcher"
            android:label="@string/app_name"
            android:theme="@style/AppTheme" >
            <activity
                android:name=".ForumActivity"
                android:theme="@android:style/Theme.NoTitleBar" />  <=== Your don't want a bar unless you further customize it

            <activity
                android:name="my.qom.forum.MainActivity" <=== Change this to your created app package name
                android:label="@string/app_name" >
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />

                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
            </activity>
        </application>

    </manifest>


    you have to add your package name .forum

[li] i was also getting this err
[/li][/list]Error: No resource found that matches the given name (at 'title' with value '@string/action_settings').

    i added in string.xml <string name="action_settings">something here</string>[/li]


  • i would like it should check if it has network conn, if not alert else continue, & on network change alert you need internet conn, to continue <back> close,

my post doesnt display properly is a bug of smf
TIA

Hj Ahmad Rasyid Hj Ismail

It has all been covered in the OP except for app notification system.
#1 - No grammar error
Quote from: ahrasis on August 24, 2014, 12:59:50 AM
To fix minor validation issue of No grammar constraints (DTD or XML schema) detected, ensure you have this code at the top of all your xml files:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE project>


#2 - Creating ForumActivity java file (obviously you have to rename it after copy paste)
Quote from: ahrasis on August 24, 2014, 12:59:50 AM
ForumActivity.java (src folder)
- You simply copy paste from the firstly created (above) java file and later change its contents as follows.

#3 - Whatever strings you used, define it in here.
Quote from: ahrasis on August 24, 2014, 12:59:50 AM
strings.xml (res/values folder)
- Language strings for your app.


#4 - Internet permission is already asked. If no internet, then no connection.
Quote from: ahrasis on August 24, 2014, 12:59:50 AM
AndroidManifest.xml (root folder)
- The main file for your app.
...
    <uses-permission android:name="android.permission.INTERNET" />


#5 - You have to have responsive theme OR mobile theme.
Quote from: ahrasis on August 24, 2014, 12:59:50 AM
First Get Ready
...
3. When your ADT is ready to be used, get mobile theme (free or paid) and install on your forum. This app will work fine but will not have its own css. It will depends on your forum mobile theme css.
4. Don't forget that you need a mod to detect and change your forum to use that mobile theme.

Note: I am in the mid of creating notification system mod and upgrading this app with it but it will take times. :)

hitsme

i would like to add a 2nd button taking to a certain board how would the java file look?

Hj Ahmad Rasyid Hj Ismail

Your forum is displayed under ForumActivity.java using its forum.xml. You need to duplicate both and rename them. Change url and button name to your preferred board url in NewBoardActivity.java and button name in board1.xml. That should cover the basic.

hitsme

Quote from: ahrasis on February 02, 2015, 09:37:32 AM
Your forum is displayed under ForumActivity.java using its forum.xml. You need to duplicate both and rename them. Change url and button name to your preferred board url in NewBoardActivity.java and button name in board1.xml. That should cover the basic.
Thanks,
my question was about the MainActivity.java adding the second button
package my.qom.forum; <=== Change this to your created app package name

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

public class MainActivity extends Activity {

private Button button;

public void onCreate(Bundle savedInstanceState) {
final Context context = this;

super.onCreate(savedInstanceState);
setContentView(R.layout.main);

button = (Button) findViewById(R.id.buttonUrl);

button.setOnClickListener(new OnClickListener() {

  @Override
  public void onClick(View arg0) {
    Intent intent = new Intent(context, ForumActivity.class);
    startActivity(intent);
  }

});
}
}



how (where) do i add a second button?
TIA i appreciate your help

Hj Ahmad Rasyid Hj Ismail

Oh yes. I forgot about that. This is not tested but I think you should be able to simply duplicate and change the duplicate copy of this code:
button = (Button) findViewById(R.id.buttonUrl);
button.setOnClickListener(new OnClickListener() {

  @Override
  public void onClick(View arg0) {
    Intent intent = new Intent(context, ForumActivity.class);
    startActivity(intent);
  }


To:
button = (Button) findViewById(R.id.buttonUrl);
button.setOnClickListener(new OnClickListener() {

  @Override
  public void onClick(View arg0) {
    Intent intent = new Intent(context, ForumActivity.class);
    startActivity(intent);
  }
button2 = (Button) findViewById(R.id.button2Url);
button2.setOnClickListener(new OnClickListener() {

  @Override
  public void onClick(View arg0) {
    Intent intent2 = new Intent(context, NewBoardActivity.class);
    startActivity(intent2);
  }



Or something like that. Make sure you add the button by simply duplicating and change the duplicate copy of the button in main.xml too. Note, you can create and apply your own css to the button and all other things including the forum itself. (Please do your own research on this)

gvill

Thank you for this tutorial !
I managed to get an apk but i can't launch it on my HTC (Android 2.3), it starts but seems to crash few seconds later. Do you think my android version might be the problem?
Thanks !

Advertisement: