I'm facing a very weird error right now. Basically, the app can search Google Places API using SearchView widget and show the results in Google Maps Android API V2, and the searchview widget is placed in action bar. I have referenced to this tutorial:
http://wptrafficanalyzer.in/blog/android-searchview-widget-with-google-places-api-using-actionbarsherlock-library/
The app works fine when the searchable activity (I name it as SearchPlace) is the main and launcher activity. However, if I try to intent to this activity from another activity, the app crash. I got NullPointerException caused by handleIntent().
I have attached a portion of the Manifest file below SearchPlace is the name of my searchable activity.
<!-- Protect the map component of the application using application signature -->
<permission
android:name="in.wptrafficanalyzer.locationsherlocksearchviewmapv2.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<!-- Allows to receive map -->
<uses-permission android:name="in.wptrafficanalyzer.locationsherlocksearchviewmapv2.permission.MAPS_RECEIVE" />
<!-- Used by the Google Maps Android API V2 to download map tiles from Google Maps servers -->
<uses-permission android:name="android.permission.INTERNET" />
<!-- Allows the Google Maps Android API V2 to cache map tile data in the device's external storage area -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!-- Allows the Google Maps Android API V2 to use WiFi or mobile cell data (or both) to determine the device's location -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<!-- Allows the Google Maps Android API V2 to use the Global Positioning System (GPS)
to determine the device's location to within a very small area -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<!-- Allows to contact Google Serves -->
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<!-- Google Maps Android API V2 requires OpenGL ES version 2 -->
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/Theme.Sherlock" >
<activity
android:name="in.wptrafficanalyzer.locationsherlocksearchviewmapv2.Home"
android:label="#string/app_name"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="in.wptrafficanalyzer.locationsherlocksearchviewmapv2.SearchPlace"
android:label="#string/app_name"
android:launchMode="singleTop"
>
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>
<!-- Points to searchable activity -->
<meta-data
android:name="android.app.default_searchable"
android:value=".SearchPlace" />
<!-- Points to searchable meta data -->
<meta-data
android:name="android.app.searchable"
android:resource="#xml/searchable" />
</activity>
<provider
android:name=".PlaceProvider"
android:authorities="in.wptrafficanalyzer.locationsherlocksearchviewmapv2.PlaceProvider"
android:exported="false" />
<!-- Specifies the Android API Key, which is obtained from Google API Console -->
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="YOUR_ANDROID_API_KEY" />
</application>
The error log is attached below. It seems like my handleIntent() caused the error.
07-31 01:49:53.685: E/AndroidRuntime(5539): java.lang.RuntimeException: Unable to start activity ComponentInfo{in.wptrafficanalyzer.locationsherlocksearchviewmapv2/in.wptrafficanalyzer.locationsherlocksearchviewmapv2.SearchPlace}: java.lang.NullPointerException
07-31 01:49:53.685: E/AndroidRuntime(5539): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
07-31 01:49:53.685: E/AndroidRuntime(5539): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
07-31 01:49:53.685: E/AndroidRuntime(5539): at android.app.ActivityThread.access$600(ActivityThread.java:141)
07-31 01:49:53.685: E/AndroidRuntime(5539): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
07-31 01:49:53.685: E/AndroidRuntime(5539): at android.os.Handler.dispatchMessage(Handler.java:99)
07-31 01:49:53.685: E/AndroidRuntime(5539): at android.os.Looper.loop(Looper.java:137)
07-31 01:49:53.685: E/AndroidRuntime(5539): at android.app.ActivityThread.main(ActivityThread.java:5041)
07-31 01:49:53.685: E/AndroidRuntime(5539): at java.lang.reflect.Method.invokeNative(Native Method)
07-31 01:49:53.685: E/AndroidRuntime(5539): at java.lang.reflect.Method.invoke(Method.java:511)
07-31 01:49:53.685: E/AndroidRuntime(5539): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
07-31 01:49:53.685: E/AndroidRuntime(5539): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
07-31 01:49:53.685: E/AndroidRuntime(5539): at dalvik.system.NativeStart.main(Native Method)
07-31 01:49:53.685: E/AndroidRuntime(5539): Caused by: java.lang.NullPointerException
07-31 01:49:53.685: E/AndroidRuntime(5539): at in.w ptrafficanalyzer.locationsherlocksearchviewmapv2.SearchPlace.handleIntent(SearchPlace.java:473)
07-31 01:49:53.685: E/AndroidRuntime(5539): at in.wptrafficanalyzer.locationsherlocksearchviewmapv2.SearchPlace.onCreate(SearchPlacer.java:129)
07-31 01:49:53.685: E/AndroidRuntime(5539): at android.app.Activity.performCreate(Activity.java:5104)
07-31 01:49:53.685: E/AndroidRuntime(5539): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
07-31 01:49:53.685: E/AndroidRuntime(5539): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
My SearchPlace Activity
#Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.google_map_v2);
handleIntent(getIntent());
}
private void handleIntent(Intent intent)
{
if(intent.getAction().equals(Intent.ACTION_SEARCH))
{
doSearch(intent.getStringExtra(SearchManager.QUERY));
}
else if(intent.getAction().equals(Intent.ACTION_VIEW))
{
getPlace(intent.getStringExtra(SearchManager.EXTRA_DATA_KEY));
}
}
#Override
protected void onNewIntent(Intent intent)
{
super.onNewIntent(intent);
setIntent(intent);
handleIntent(intent);
}
private void doSearch(String query)
{
Bundle data = new Bundle();
data.putString("query", query);
getSupportLoaderManager().restartLoader(0, data, this);
}
private void getPlace(String query)
{
Bundle data = new Bundle();
data.putString("query", query);
getSupportLoaderManager().restartLoader(1, data, this);
}
#Override
public Loader<Cursor> onCreateLoader(int arg0, Bundle query)
{
CursorLoader cLoader = null;
if(arg0 == 0)
cLoader = new CursorLoader(getBaseContext(),
PlaceProvider.SEARCH_URI, null, null, new String[]
{ query.getString("query") }, null);
else if(arg0 == 1)
cLoader = new CursorLoader(getBaseContext(),
PlaceProvider.DETAILS_URI, null, null, new String[]
{ query.getString("query") }, null);
return cLoader;
}
#Override
public void onLoadFinished(Loader<Cursor> arg0, Cursor c)
{
showLocations(c);
}
#Override
public void onLoaderReset(Loader<Cursor> arg0)
{
// TODO Auto-generated method stub
}
Can anyone help me plz ?
Thank you
Problem solved, modify the handleIntent() as
if(Intent.ACTION_SEARCH.equals(intent.getAction()))
{
String query = intent.getStringExtra(SearchManager.QUERY);
doSearch(query);
}
else if(Intent.ACTION_VIEW.equals(intent.getAction()))
{
getPlace(intent.getStringExtra(SearchManager.EXTRA_DATA_KEY));
}
Related
I need some assistance on my final capstone design project for my university. My question is, How can I develop an android studio code (Kotlin) for Facebook in order to show Live videos from a "Client" website?
I already have a working code that shows the client's website, just need to be able to show his Live videos. This work is to finish my bachelor's degree in ELECTRICAL engineering, so no previous experience in programming apart from the C++ classes that I took 3 years ago.
This is the code i have now,
class FacebookActivity : AppCompatActivity() {
private lateinit var callbackManager: CallbackManager
/**
* This creates the page for Facebook login
*/
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_facebook)
// Initialize the Facebook Login callback manager
callbackManager = CallbackManager.Factory.create()
// Register a callback for the Facebook Login button
btnLogin.registerCallback(callbackManager, object : FacebookCallback<LoginResult> {
// If the Facebook Login is successful
override fun onSuccess(loginResult: LoginResult) {
Log.d("FacebookActivity", "Facebook token: " + loginResult.accessToken.token)
startFacebookPage()
}
// If the Facebook Login is cancelled
override fun onCancel() {
Log.d("FacebookActivity", "Facebook Login cancelled.")
}
// If there is an error during the Facebook Login
override fun onError(error: FacebookException) {
Log.d("FacebookActivity", "Facebook Login error: " + error.message)
}
})
// Check if the user is already logged in to Facebook
if (AccessToken.isCurrentAccessTokenActive()) {
startFacebookPage()
} else {
// Log in the user with read permissions if they are not already logged in
LoginManager.getInstance().logInWithReadPermissions(this, listOf("public_profile"))
}
}
// Start the Facebook page
private fun startFacebookPage() {
val facebookIntent = Intent(Intent.ACTION_VIEW).apply {
data = Uri.parse("https://www.facebook.com/radiodiosmedijonotecalles")
}
startActivity(facebookIntent)
}
/**
* This allows to go "back"
*/
override fun onSupportNavigateUp(): Boolean {
onBackPressedDispatcher.onBackPressed()
return true
}
}
And the Manifest;
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.INTERNET" />
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:resizeable="true"
android:smallScreens="true"
android:xlargeScreens="true" />
<application
android:allowBackup="true"
android:dataExtractionRules="#xml/data_extraction_rules"
android:enableOnBackInvokedCallback="true"
android:fullBackupContent="#xml/backup_rules"
android:icon="#mipmap/ic_launcher2"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher2_round"
android:supportsRtl="true"
android:theme="#style/Theme.RadioDiosMeDijoNoTeCalles"
tools:targetApi="33">
<activity
android:name=".ClientActivity"
android:configChanges="keyboardHidden|orientation|screenSize|screenLayout|touchscreen|smallestScreenSize"
android:exported="false" />
<activity
android:name=".AboutThisAppActivity"
android:configChanges="keyboardHidden|orientation|screenSize|screenLayout|touchscreen|smallestScreenSize"
android:exported="false" />
<activity
android:name=".FacebookActivity"
android:configChanges="keyboardHidden|orientation|screenSize|screenLayout|touchscreen|smallestScreenSize"
android:exported="true" />
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="#string/facebook_app_id" />
<meta-data
android:name="com.facebook.sdk.ClientToken"
android:value="#string/facebook_client_token" />
<activity
android:name=".ZenoRadioActivity"
android:configChanges="keyboardHidden|orientation|screenSize|screenLayout|touchscreen|smallestScreenSize"
android:exported="false"
android:screenOrientation="portrait"
tools:ignore="LockedOrientationActivity" />
<activity
android:name=".YouTubeActivity"
android:configChanges="keyboardHidden|orientation|screenSize|screenLayout|touchscreen|smallestScreenSize"
android:exported="false" />
<activity
android:name=".LinksActivity"
android:exported="false" />
<activity
android:name=".TwitchActivity"
android:configChanges="keyboardHidden|orientation|screenSize|screenLayout|touchscreen|smallestScreenSize"
android:exported="false" />
<activity
android:name=".DonationsActivity"
android:configChanges="keyboardHidden|orientation|screenSize|screenLayout|touchscreen|smallestScreenSize"
android:exported="false" />
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Any and all Help will be greatly appreciated!
I'm trying to get deep links to work for my maui android app but when I click to open the link with the app I get this error:
Java.Lang.RuntimeException: 'Unable to instantiate activity ComponentInfo{app.mydomain/MyApp.Client.MAUI.MainActivity}:
java.lang.ClassNotFoundException: Didn't find class "MyApp.Client.MAUI.MainActivity"
on path: DexPathList[[zip file "/data/app/~~0C9vYHAHNOr9CaB4f63clQ==/app.mydomain-YYQ6ZPc3-KSVnF8_VcuQVQ==/base.apk"],
nativeLibraryDirectories=[/data/app/~~0C9vYHAHNOr9CaB4f63clQ==/app.mydomain-YYQ6ZPc3-KSVnF8_VcuQVQ==/lib/arm64,
/data/app/~~0C9vYHAHNOr9CaB4f63clQ==/app.mydomain-YYQ6ZPc3-KSVnF8_VcuQVQ==/base.apk!/lib/arm64-v8a, /system/lib64,
/system_ext/lib64]]'
My MainActivity.cs looks like this
namespace MyApp.Client.MAUI
{
[Activity(Theme = "#style/Maui.SplashTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)]
[IntentFilter(new[] { Intent.ActionView }, Categories = new[] { Intent.CategoryDefault, Intent.CategoryBrowsable },
DataScheme = "https", DataHost = "mydomain.app", DataPathPattern = "/.*", AutoVerify = true)]
public class MainActivity : MauiAppCompatActivity
{
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
}
protected override void OnResume()
{
base.OnResume();
Platform.OnResume(this);
}
protected override void OnNewIntent(Intent intent)
{
base.OnNewIntent(intent);
var data = intent.DataString;
if (intent.Action != Intent.ActionView) return;
if (string.IsNullOrWhiteSpace(data)) return;
var path = data.Replace(#"https://mydomain.app", "");
//todo - handle path
StartActivity(typeof(MainActivity));
}
}
The intent filter in the AndroidManifest.xml is like so:
<activity android:name="MyApp.Client.MAUI.MainActivity" android:exported="true">
<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="https" android:host="mydomain.app" android:pathPattern="/.*" />
</intent-filter>
</activity>
I could reproduce your problem.
And I can resolve this problem by adding tag <application> inside of AndroidManifest.xml.
You can refer to the full code of AndroidManifest.xml on my side:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<application android:allowBackup="true" android:supportsRtl="true" android:theme="#style/AppTheme" android:name="android.app.Application" android:debuggable="true" android:extractNativeLibs="true">
<activity android:name="MauiBlazorApp.MainActivity" android:exported="true">
<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="https" android:host="mydomain.app" android:pathPattern="/.*" />
</intent-filter>
</activity>
</application>
</manifest>
Note: Remember to change the value of android:name(YourAppName) of your activity to yours.
<application android:name="YourAppName.MainActivity">
I want to create a test project works 'facebook login'.
I made with reference to the developers site and blog equal, But I met with an error message on xml.
[error massage]
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.facebooktest.zoit.facebooktest/com.facebooktest.zoit.facebooktest.MainActivity}: android.view.InflateException: Binary XML file line #8: Error inflating class com.facebook.login.widget.LoginButton
[xml]
<com.facebook.login.widget.LoginButton
android:id="#+id/facebook_login_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="30dp"
android:layout_marginTop="30dp" />
[Manifest]
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.facebooktest.zoit.facebooktest">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="#string/fb_login_protocol_scheme" />
</intent-filter>
</activity>
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="#string/facebook_app_id" />
</application>
<uses-permission android:name="android.permission.INTERNET" />
<activity
android:name="com.facebook.FacebookActivity"
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="#string/app_name"
android:theme="#android:style/Theme.Translucent.NoTitleBar" />
</manifest>
[MainActivity]
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
FacebookSdk.sdkInitialize(getApplicationContext());
AppEventsLogger.activateApp(this);
facebookLoginButton.registerCallback(callbackManager,
new FacebookCallback<LoginResult>() {...
...
public void onActivityResult(...
void geHashKey(){...
void geHashKey(){ ...
public void onResume(){ ...
public void onPause(){...
Do you know what's wrong? please help.
I know!
FacebookSdk.sdkInitialize(getApplicationContext());
AppEventsLogger.activateApp(this);
setContentView(R.layout.activity_main);
"setContentView(R.layout.activity_main);"
I succeeded to move the this code below to Facebook code.
D
I need you help.
I have a activity ( the login Screen ), she extends of Activity!
My APP, have 3 tab, she extends of TabActivity.
I need write this code with tabactivity(deprecated). ;D
My problem is: When I click button in the Login Screen(Activity) , I want to call my activity(TabAcitivty), but when i make this, show up only a screen white =\
My ScreenLogin
public class TelaLogin extends Activity{
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.act_login);
Button btnGoogle = (Button) findViewById(R.id.btn_google);
btnGoogle.setOnClickListener(new View.OnClickListener() {
#Override
**public void onClick(View v) {
Intent myIntent = new Intent(getApplicationContext(), TabBar.class);
startService(myIntent);
setContentView(R.layout.act_frag_tab_bar);
}**
});
}
}
My TabActivity
public class TabBar extends TabActivity implements OnTabChangeListener {
... The code is "Maceta"(Large)
}
R.layout.act_frag_tab_bar have my 3 Tabs.
package com.example.androidtablayout;
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 AndroidActivity extends Activity {
// button to show progress dialog
Button btnCallTabActivity;
Context con;
public static final int progress_bar_type = 0;
// File url to download
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mains);
con=this;
// show progress bar button
btnCallTabActivity = (Button) findViewById(R.id.btnTabActivity);
// Image view to show image after downloading
/**
* Show Progress bar click event
* */
btnCallTabActivity.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
Intent i = new Intent(con, AndroidTabLayoutActivity.class);
startActivity(i);
}
});
}
/**
* Showing Dialog
* */
}
And your Tab Activity should be like this
package com.example.androidtablayout;
import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;
public class AndroidTabLayoutActivity extends TabActivity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TabHost tabHost = getTabHost();
// Tab for Photos
TabSpec photospec = tabHost.newTabSpec("Photos");
photospec.setIndicator("Photos", getResources().getDrawable(R.drawable.icon_photos_tab));
Intent photosIntent = new Intent(this, PhotosActivity.class);
photospec.setContent(photosIntent);
// Tab for Songs
TabSpec songspec = tabHost.newTabSpec("Songs");
// setting Title and Icon for the Tab
songspec.setIndicator("Songs", getResources().getDrawable(R.drawable.icon_songs_tab));
Intent songsIntent = new Intent(this, SongsActivity.class);
songspec.setContent(songsIntent);
// Tab for Videos
TabSpec videospec = tabHost.newTabSpec("Videos");
videospec.setIndicator("Videos", getResources().getDrawable(R.drawable.icon_videos_tab));
Intent videosIntent = new Intent(this, VideosActivity.class);
videospec.setContent(videosIntent);
// Adding all TabSpec to TabHost
tabHost.addTab(photospec); // Adding photos tab
tabHost.addTab(songspec); // Adding songs tab
tabHost.addTab(videospec); // Adding videos tab
}
}
I edit my manifest.xml and added that lines:
<activity android:name="tcc.sigme.TabBar" >
</activity>
<activity android:name="tcc.sigme.Tab01" >
</activity>
<activity android:name="tcc.sigme.Tab02" >
</activity>
<activity android:name="tcc.sigme.Tab03" >
</activity>
you see in : https://github.com/EdilsonGalvao/SigMe/blob/master/SigME/AndroidManifest.xml
Thanks a lot.
this is my manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="tcc.sigme"
android:versionCode="1"
android:versionName="1.0" >
<!-- Permission Uses Google Maps -->
<uses-permission android:name="permission_name" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-sdk
android:minSdkVersion="13"
android:targetSdkVersion="19" />
<!-- Unable OpenGL for run Maps -->
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen" >
<!-- Google API Key -->
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyCizmQT2lm48beRhFFa78kjEqoamFke9iM" />
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<activity
android:name="tcc.sigme.TelaLogin"
android:label="#string/app_name"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="tcc.sigme.TabBar" >
</activity>
<activity android:name="tcc.sigme.Tab01" >
</activity>
<activity android:name="tcc.sigme.Tab02" >
</activity>
<activity android:name="tcc.sigme.Tab03" >
</activity>
</application>
</manifest>
My app crashes every time I try to launch the RegisterActivity. I have swapped out several other activities and the button launches them. Just not RegisterActivity. It is in the Manifest and there are no errors. I cannot figure out the problem. Any help will be greatly appreciated. Code follows:
// Link to Register Screen
btnLinkToRegister.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent intent = new Intent(v.getContext(), RegisterActivity.class);
startActivityForResult(intent, 0);
The Activity that crashes the app:
package com.dip.allnavyinfo;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
public class RegisterActivity extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Set View to register.xml
setContentView(R.layout.register);
TextView loginScreen = (TextView) findViewById(R.id.link_to_login);
// Listening to Login Screen link
loginScreen.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
// Closing registration screen
// Switching to Login Screen/closing register screen
finish();
}
});
}
}
LogCat:
08-25 06:44:15.677: E/AndroidRuntime(1200): FATAL EXCEPTION: main
08-25 06:44:15.677: E/AndroidRuntime(1200): java.lang.RuntimeException: Unable to instantiate application android.app.Application: java.lang.IllegalStateException: Unable to get package info for com.dip.allnavyinfo; is package not installed?
08-25 06:44:15.677: E/AndroidRuntime(1200): at android.app.LoadedApk.makeApplication(LoadedApk.java:509)
08-25 06:44:15.677: E/AndroidRuntime(1200): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4417)
08-25 06:44:15.677: E/AndroidRuntime(1200): at android.app.ActivityThread.access$1300(ActivityThread.java:141)
08-25 06:44:15.677: E/AndroidRuntime(1200): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316)
08-25 06:44:15.677: E/AndroidRuntime(1200): at android.os.Handler.dispatchMessage(Handler.java:99)
08-25 06:44:15.677: E/AndroidRuntime(1200): at android.os.Looper.loop(Looper.java:137)
08-25 06:44:15.677: E/AndroidRuntime(1200): at android.app.ActivityThread.main(ActivityThread.java:5103)
08-25 06:44:15.677: E/AndroidRuntime(1200): at java.lang.reflect.Method.invokeNative(Native Method)
08-25 06:44:15.677: E/AndroidRuntime(1200): at java.lang.reflect.Method.invoke(Method.java:525)
08-25 06:44:15.677: E/AndroidRuntime(1200): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
08-25 06:44:15.677: E/AndroidRuntime(1200): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
08-25 06:44:15.677: E/AndroidRuntime(1200): at dalvik.system.NativeStart.main(Native Method)
08-25 06:44:15.677: E/AndroidRuntime(1200): Caused by: java.lang.IllegalStateException: Unable to get package info for com.dip.allnavyinfo; is package not installed?
08-25 06:44:15.677: E/AndroidRuntime(1200): at android.app.LoadedApk.initializeJavaContextClassLoader(LoadedApk.java:369)
08-25 06:44:15.677: E/AndroidRuntime(1200): at android.app.LoadedApk.getClassLoader(LoadedApk.java:322)
08-25 06:44:15.677: E/AndroidRuntime(1200): at android.app.LoadedApk.makeApplication(LoadedApk.java:501)
08-25 06:44:15.677: E/AndroidRuntime(1200): ... 11 more
Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.dip.allnavyinfo"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".SplashScreenActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- Main Activity -->
<activity
android:name=".MainActivity"
android:label="#string/main" >
</activity>
<activity
android:name=".Bibs"
android:label="#string/title_activity_bibs" >
</activity>
<activity
android:name=".LoginActivity"
android:label="#string/lgnlbl">
</activity>
<activity
android:name=".RegisterActivity"
android:label="#string/reglbl">
</activity>
</application>
<uses-permission
android:name="android.permission.INTERNET" />
</manifest>
1- make sure that you have defined the activity RegisterActivity in your Manifest
2- change this :
Intent intent = new Intent(v.getContext(), RegisterActivity.class);
startActivityForResult(intent, 0);
into
Intent intent = new Intent(yourCurrentActivity.this, RegisterActivity.class);
startActivity(intent);
I had the same problem, I fixed it by sorting out my async tasks. I was making two calls in the same thread, once I separated them into two threads the problem was solved.