1

I am using Jdeveloper 11.1.2.4.0 to create splashscreen..I have followed each steps stated in http://www.androidaspect.com/2012/12/android-splash-screen-tutorial.html

But still I am not able to fix the problem.

Here is my splash.java (Main activity)

package mobile;

import android.app.Activity;

import android.content.Intent;

import android.os.Bundle;

import android.view.Window;


public class Splash extends Activity {
     private long ms=0;
     private long splashTime=2000;
     private boolean splashActive = true;
     private boolean paused=false;

    /**
     * @param savedInstanceState
     */

     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);

        //Hides the titlebar
         this.requestWindowFeature(Window.FEATURE_NO_TITLE);

         setContentView(R.layout.Splash);

        Thread mythread = new Thread() {
             public void run() {
                 try {
                     while (splashActive && ms < splashTime) {
                         if(!paused)
                             ms=ms+100;
                         sleep(100);
                     }
                 } catch(Exception e) {}
                 finally {
                    Intent intent;
                    intent = new Intent(Splash.this, Home.class);
                    startActivity(intent);
                 }
             }
         };
         mythread.start();
     }
 }

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.company.splash_screen">
  <uses-sdk/>

  <application android:icon="@drawable/adfmf_icon"
    android:label="@string/app_name" android:name="oracle.adfmf.Application">
    <activity android:screenOrientation="fullSensor" android:name=".Splash"      android:noHistory="true" android:label="@string/app_name" android:theme="@android:style/Theme.NoTitleBar"
              android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|screenLayout|fontScale|uiMode|orientation" android:windowSoftInputMode="adjustPan" >
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
       <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
    </activity>


        <activity
             android:name=".Home"
             android:label="@string/title_activity_home" >
         </activity>


    <activity android:name="oracle.adfmf.AMXActivity" android:theme="@android:style/Theme.NoTitleBar" android:windowSoftInputMode="adjustPan"></activity>
    <activity android:name="oracle.adfmf.RemoteURLActivity" android:theme="@android:style/Theme.NoTitleBar" android:windowSoftInputMode="adjustPan"></activity>
    <activity android:name="oracle.adfmf.LocalHTMLActivity" android:theme="@android:style/Theme.NoTitleBar" android:windowSoftInputMode="adjustPan"></activity>
    <activity android:name="oracle.adfmf.phonegap.AdfSpringboardPhoneGapActivity" android:theme="@android:style/Theme.NoTitleBar" android:windowSoftInputMode="adjustPan"></activity>
    <activity android:name="oracle.adfmf.SettingsActivity" android:theme="@android:style/Theme.NoTitleBar" android:windowSoftInputMode="adjustPan"></activity>
    <activity android:name="oracle.adfmf.navbar.MoreTabActivity" android:theme="@android:style/Theme.NoTitleBar" android:windowSoftInputMode="adjustPan"></activity> 
    <activity android:name="oracle.adfmf.BlankActivity" android:theme="@android:style/Theme.NoTitleBar" android:windowSoftInputMode="adjustPan"></activity>
    <receiver android:name="com.google.android.gcm.GCMBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND" >
      <intent-filter>
        <action android:name="com.google.android.c2dm.intent.RECEIVE" />
        <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
        <category android:name="com.company.splash_screen" />
      </intent-filter>
    </receiver>
    <service android:name=".GCMIntentService" />
  </application>

  <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
  <uses-permission android:name="android.permission.CAMERA" />
  <uses-permission android:name="android.permission.VIBRATE" />
  <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
  <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
  <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
  <uses-permission android:name="android.permission.READ_PHONE_STATE" />
  <uses-permission android:name="android.permission.INTERNET" />
  <uses-permission android:name="android.permission.RECEIVE_SMS" />
  <uses-permission android:name="android.permission.RECORD_AUDIO" />
  <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
  <uses-permission android:name="android.permission.READ_CONTACTS" />
  <uses-permission android:name="android.permission.WRITE_CONTACTS" />   
  <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />   
  <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
  <uses-permission android:name="android.permission.GET_ACCOUNTS" />
  <permission android:name="com.company.splash_screen.permission.C2D_MESSAGE" android:protectionLevel="signature" />
  <uses-permission android:name="com.company.splash_screen.permission.C2D_MESSAGE" />
  <!-- App receives GCM messages. -->
  <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
  <!-- GCM connects to Google Services. -->
  <uses-permission android:name="android.permission.INTERNET" /> 
  <!-- GCM requires a Google account. -->
  <uses-permission android:name="android.permission.GET_ACCOUNTS" />
  <!-- Keeps the processor from sleeping when a message is received. -->
  <uses-permission android:name="android.permission.WAKE_LOCK" /> 

</manifest>

in res/layout/ folder ,I have splash.xml

<?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent"
     android:orientation="vertical" >

    <ImageView
         android:id="@+id/image"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:src="@drawable/background" />

    <ProgressBar
         android:id="@+id/progressBar1"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_below="@id/image"
         android:layout_gravity="center_horizontal" >
     </ProgressBar>

</LinearLayout> 

and home.xml (second activity)

<?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:orientation="vertical" >

    <TextView
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_gravity="center"
         android:layout_marginTop="20dip"
         android:text="HomeScreen"
         android:textAppearance="?android:attr/textAppearanceLarge" />

</LinearLayout>

In both .java files (splash.java & home.java) error is showing at setContentView(R.layout.Splash); and setContentView(R.layout.Home); resp...

user2447044
  • 69
  • 3
  • 8

2 Answers2

4

Your R.java file is not being generated properly.

Clean the project and build it again.

Project -> Clean

If that does not solve the problem, check for errors in your XML files. Errors in the XML files prevent the generation of R.java.

Once you are sure that everything is correct, you can either clean the project and build it again.

Or you can manually delete R.java and then build the project, which will regenerate R.java once again.

NOTE: Never use import android.r, even if you see eclipse suggesting it.

Swayam
  • 16,294
  • 14
  • 64
  • 102
  • Please tell me how to fix it in jdeevloper – user2447044 Jun 04 '13 at 06:17
  • Thnks..Still same error..R.java file is get created but the package where R.java is present is not accessible from another java file..means I cant import my R.java package.It is giving error saying package not found.. :( – user2447044 Jun 04 '13 at 06:55
  • What are you using in the classes as the package name ? – Swayam Jun 04 '13 at 07:06
  • R.java is getting created at two places 1..com.company.splash_screen(splashscreen is my application name) and 2..src.oracle.idm.mobile..I used 1 of these package name in my java class – user2447044 Jun 04 '13 at 07:17
  • Yeah, right. You should be using the R file for your package and not for the other one. – Swayam Jun 04 '13 at 07:27
  • "You should be the R file for your package and not for the other one" can you please explain this line? – user2447044 Jun 04 '13 at 07:29
  • I meant you should be using `import com.company.splashscreen.R` – Swayam Jun 04 '13 at 07:30
  • I tried that also..error is throwing saying package not found.. :(..This framework is headache only ..we cant easily create even a simple task also – user2447044 Jun 04 '13 at 07:31
  • The main problem is that everyone uses eclipse. I cant really help you because I dont know the commands and fixes for the IDE that you are using. – Swayam Jun 04 '13 at 07:32
  • Try one last thing. Go to the file explorer on your system and go to the `gen` folder. Check if the R.java exists in the appropriate location, as in *gen->com->company->splashscreen->R.java* – Swayam Jun 04 '13 at 07:38
  • And you didnt tell me why you are using `package mobile` in your code ? – Swayam Jun 04 '13 at 07:40
  • my two activities Splash.java & Home.java are created in package mobile..Should I create those files in same package as R.java? – user2447044 Jun 04 '13 at 07:42
  • gen folder is nt present ini this framework..instead tha res folder is there – user2447044 Jun 04 '13 at 07:42
  • `res` folder is there while developing on eclipse too. So if you dont have `gen`, I am guessing that your auto-generated files are not being created due to some reason. And yes, try to maintain a common package name for the whole application. – Swayam Jun 04 '13 at 08:52
0

You dint import it,

put this in your imports

import (Your package Name ex:com.android.user).R

and make sure you have the R.java file in (Project->gen>projectname->R.java) if you dont then go to (right click project-> android tools -> fix project properties.)

Saad
  • 309
  • 2
  • 9
  • 21