I know that this question was already write, and it's that why , i post my question because it's very strange...
I just want to go to an other activity since OnPostExecute() of my AsyncTask.
So i saw that this line works :
this.context.startActivity(new Intent(this.context, com.ListCrossingPoint.ListCrossingPoint.class));
Where this.context is the context of the start activity , which is in the constructor of the asyntask and com.ListCrossingPoint.ListCrossingPoint.class is the class reach, which is in other package.
And thinking that it's will work well , i have this error :
03-11 14:59:22.304: E/AndroidRuntime(1041): FATAL EXCEPTION: main
03-11 14:59:22.304: E/AndroidRuntime(1041): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.main/com.ListCrossingPoint.ListCrossingPoint};
have you declared this activity in your AndroidManifest.xml?
03-11 14:59:22.304: E/AndroidRuntime(1041): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1541)
03-11 14:59:22.304: E/AndroidRuntime(1041): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1416)
...
So , i went to see if my activity was declare and , yess, it declared, so i don't understand ..
<activity android:name="com.listcrossingpoint.ListCrossingPoint" android:label="#string/menu_point_list"
android:configChanges="orientation" android:screenOrientation="landscape" />
you have a typo in
com.ListCrossingPoint.ListCrossingPoint.class
that mismatch with the entry in the Manifest. It should be
com.listCrossingPoint.ListCrossingPoint.class
you have the capital L in the Intent constructor, but it is lower case in the AndroidManifest.xml
Woohoo Its an issue of Spell Mistake. What you have defined in AndroidManifest.xml is
<activity android:name="com.listcrossingpoint.ListCrossingPoint" android:label="#string/menu_point_list"
android:configChanges="orientation" android:screenOrientation="landscape" />
And you are calling
this.context.startActivity(new Intent(this.context, com.ListCrossingPoint.ListCrossingPoint.class));
this in Intent. Its a problem of Package Name.
Change this ListCrossingPoint to listcrossingpoint.
Can you rename your package to listcrossingpoint with lowercase?, you mustn't use uppercase to package names.
You can use refactor/rename in eclipse to do it. (Alt+Shift+R)
I assume it is due to the wrong spelling:
in startActivity() you call
"com.ListCrossingPoint.ListCrossingPoint.class"
in the Manifest you have
"com.listcrossingpoint.ListCrossingPoint"
(upper and lower case L)
i resolved my problem. I renamed the package com.listpoint , like this , there is no ambiguity and i verify all reference and it's work. Thank everybody =)
Related
I want to launch a specific activity of another app from my app. For example, on the onCreate of my app, I want to launch the activity named Rolling (not main) activity of com.pas.webcam.pro. I have heard that you must have control of both apps to do this because you must add an intent filter to the manifest of the second app. This is not true though, because activity launcher apps in the Google Play Store can launch the Rolling Activity of IP Webcam Pro.
The Activity Launcher app is open source, so I tried reviewing the source code here. It was too complicated though, so I could not figure out how this app magically launches this activity. There are many other questions like this on Stack Overflow, and I have read every one. I have also tried lots of the code from the answers too, like this:
Intent intent = new Intent(); intent.setComponent(new ComponentName("com.pas.webcam", "com.pas.webcam.RollingActivity")); startActivity(intent);
I have also tried variants of this code from other posts. My app always crashes and I get variants (depending on the code I use) of the following error:
An error occurred
Invalid intent operation. Unable to find explicit activity class {com.pas.webcam.pro/com.pas.webcam.pro.Rolling}; have you declared this activity in your AndroidManifest.xml?
I have put both of the following in my Android Manifest and the same thing happens:
<uses-permission android:name="android.permission.GET_INSTALLED_PACKAGES" />
<activity android:name="com.pas.webcam.pro.RollingActivity"
Thanks in advance for any answers, I really appreciate it, as I have been working on this problem for a while.
Edit: Here is the activity of the app I want to launch: https://i.stack.imgur.com/Fa7Xq.jpg
Edit: David Wasser helped me solve the problem by giving me the code neccessary to solve the problem. It actually works! To anyone who wants to launch a specific activity of another app with code, please use this:
Intent intent = new Intent(); intent.setClassName("com.pas.webcam.pro", "com.pas.webcam.Rolling"); startActivity(intent);
You may replace com.pas.webcam.pro and Rolling with the app and activity of your choice, but this method truly works. Problem Solved!😀
Try this:
Intent intent = new Intent();
intent.setClassName("com.pas.webcam.pro", "com.pas.webcam.Rolling");
startActivity(intent);
Since you refer to the app as "IP webcam pro", I'm assuming the package name is "com.pas.webcam.pro" (found by Internet research).
I have been trying to fully understand nkzawa's android example on github for socket.io
Relative link:
https://github.com/nkzawa/socket.io-android-chat/tree/master/app/src/main/java/com/github/nkzawa/socketio/androidchat
(AndoridManifest.xml is in the "main" folder)
I have been told that android decides which activity to run first from a tag inside AndroidManifest.xml that would have < action ... .MAIN and < category ... .LAUNCHER inside the activity. When I look at AndroidManifest.xml I see the aforementioned tags inside of the MainActivity declaration. Great! So MainActivity must be the first to run. Now, when I look at MainActivity.java I see an onCreate() method that just sets the content view with not much else to be seen.... So how does the LoginActivity start?
I have setup the server side of things without an issue and I can compile and run the example, connect to my server and all that... I just don't understand how the onCreate() method is first called for the LoginActivity.
There is definitely something I am missing. The LoginActivity must be started somewhere else besides AndroidMainifest.xml or MainActivity.java..
If anyone could point me in the right direction even it would be great! Thanks so much.
Alright I think I got it.
1. App starts at MainActivity.onCreate()
2. Sets content view with: setContentView(R.layout.activity_main)
3. Activity_main.xml opens a fragment that uses class MainFragment
4. MainFragment.onCreate() does some work then calls startSignIn()
5. startSignIn() calls startActivityForResult(intent, REQUEST_LOGIN) with the intent as the LoginActivity!
Now the LoginActivity has begun :)
I have 2 product flavor. Let's say the example like this:
productFlavors {
free {
applicationId 'com.free.android'
}
premium {
applicationId 'com.premium.android'
}
My problem is when i use
Intent resultIntent = new Intent(this, ExpiryListActivity.class);
TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
stackBuilder.addParentStack(ExpiryListActivity.class);
stackBuilder.addNextIntent(resultIntent);
The problem happened when stackBuilder.addParentStack(ExpiryListActivity.class)
The first app which used the productFlavor free doesn't cause android.content.pm.PackageManager$NameNotFoundException error.
But the second app which used the productFlavor premium it causes android.content.pm.PackageManager$NameNotFoundException.
Then i read the docs that stackBuilder.addParentStack(<Class>) Add the activity parent chain as specified by manifest . How to solve this problem?
TL;DR
change your metadata as
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="originalPackageName.ui.MainActivity" />
The basic problem is that gradle is expanding the package name for the parent activity class that you wrote in the metadata.
In case of your free product flavor it tries to find a class at location com.free.android.ui.MainActivity
And in case of your paid flavor it tries to find a class at location com.premium.android.ui.MainActivity
But gradle actually does not restructure the packages when you mention different applicationId's for your product flavors and the class is still located at originalPackageName.ui.MainActivity and hence the NameNotFoundException
where originalPackageName is a placeholder for the package name you started your project with.
Looks like i found it. On AndroidManifest.xml
<activity
android:name=".ui.ExpiryListActivity"
android:label="#string/voucher_expiry_list"
android:screenOrientation="portrait"
android:theme="#style/AppTheme.NoActionBar.Slidable" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".ui.MainActivity" />
</activity>
I replace the meta-data name by:
<activity
android:name=".ui.ExpiryListActivity"
android:label="#string/voucher_expiry_list"
android:screenOrientation="portrait"
android:theme="#style/AppTheme.NoActionBar.Slidable" >
<meta-data
android:name=".ui.ExpiryListActivity"
android:value=".ui.MainActivity" />
</activity>
It works, but when pressing back it cannot return to MainActivity. But, I know if this is not the best solution. Please let me know if there is another better solution.
NB: This seems only happened on Android Lollipop (5.0)
I use the Library:
https://github.com/lvillani/android-cropimage
for adding crop activity in my project.I import this library and add in my project now I am writing this code :
String mPackage = "com.android.camera";
String mClass = ".CropImage";
intent.setComponent(new ComponentName(mPackage,mPackage+mClass));
startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE);
It gives error :
Unable to find explicit activity class {com.android.camera/com.android.camera.CropImage}; have you declared this activity in your AndroidManifest.xml?
I tried to write in AndroidManifest.xml in my project ass well but still the same error.
Step #1: Add an <activity> element to your manifest pointing to com.android.camera.CropImage
Step #2: Use new Intent(this, com.android.camera.CropImage.class) to create your Intent
Step #3: There should be no step #3 AFAIK
Add activity like this in your android manifest file,
...
....
</activity>
<!-- Declare the bundled CropImage Activity -->
<activity android:name="com.android.camera.CropImage"/>
</application>
</manifest>
Documentation indeed helps :) link
does not compile. Indeed: even in 1.5, this api, getIntent(), is already listed as deprecated.
The error message I get complains that getIntent() does not return a String, but setCurrentTab() expects a string.
If I guess and change the line to read:
"tabHost.setCurrentTab(1); // was setCurrentTab(getIntent())",
then it compiles, builds, but does not run. I get the "stopped unexpectedly" error message from the emulator. I cannot even get Log.d to output, so it seems that it stops 'unexpectedly' very early.
So the first and main question is: what is the correct fix to "tabHost.setCurrentTab(getIntent())" in the final line of OnCreate() in http://developer.android.com/resources/tutorials/views/hello-tabwidget.html?
The second and simpler question is: did I guess right in replacing 'mTabHost' with tabHost in the one place where that occurs?
Here's the problems and fixes for that particular tutorial:
Step 2: When creating your activities, if you do not create them through the manifest then you'll need to add them to the manifest manually.
Add these lines to AndroidManifest.xml:
<activity android:name=".AlbumsActivity"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar">
</activity>
<activity android:name=".ArtistsActivity"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar">
</activity>
<activity android:name=".SongsActivity"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar">
</activity>
Step 3: You are only instructed to create the ic_tab_artists.xml file. You'll need to create one for ic_tab_songs.xml and ic_tab_albums.xml as well. You can just duplicate the ic_tab_artists.xml (or change the HelloTabView.java tab specs to use the artists.xml file for each tab).
Step 4: The third to last line under /res/layout/main has a typo (a ; instead of a :)
android:padding="5dp" />
</LinearLayout>
</TabHost>
Step 6: There is a typo that uses calls mTabHost instead of tabHost. Change it.
As already cited the getIntent() function on the last line isn't appropriate. I just call the tab based on it's id. eg:
tabHost.setCurrentTabByTag("albums");
At the Informal Android Meetup, I was able to confirm that my first guess was in the ballpark: the line as printed in the tutorial really is wrong, it should be replaced with something like, "tabHost.setCurrentTab(0); // was setCurrentTab(getIntent())".
There was one other major omission I had to fix before I could get the HelloTabWidget Tutorial to run: Albums|Artists|SongsActivity all had to be added to the manifest, manifest.xml. Somehow, the tutorial instructions managed to omit mention of this requirement.