project: qt5.10/android/qml
I need to use the icon from the resources - R. drawable.icon
Code below is successfully built. But it uses the name of the application package.
import myapp.foobar.com.R;
...
.setSmallIcon(R.drawable.icon)
I would like to import an R package without being bound to the application package name. Is that possible?
Or maybe there is a way to access resources without importing the R package?
Or import R-package by specifying the name of the main package indirectly? something like this: import auto.R
No, its not possible...R will always consist of Package name with starting
Related
When I upgraded my android project to android-maps-utils to 0.5+,
the entire geojson package was missing.
The geojson Class moved in to package com.google.maps.android.*data*.geojson.
Changing the import to:
import com.google.maps.android.data.geojson.*
Why am i having to go all the way in my class so he can recognize this layout i created? Because it simply does not recognize as R.layout.my_layout
OK:
super(context, com.example.leonardoinhoqui.tcc2.R.layout.my_layout);
Problem:
super(context,R.layout.my_layout);
Most probably you have a wrong import in your code (this sometimes happen when Android Studio resolves imports)
import android.R.*;
and because of that you have to provide the full name of your own R package
When my "ExampleAdapter" class is in the sample package as my MainActivity, I don't get an error. Let's say my MainActivity is in "com.example". When I create a new package inside of the "com.example" package (let's say "com.example.adapters"), and move my "ExampleAdapter" to the new package, I get the dreaded error, "Cannot resolve symbol 'R'". Why does it matter which package my adapter is in?
Why does it matter which package my adapter is in?
The R and BuildConfig classes are always code-generated into the Java package that you name in the package attribute of your <manifest> element in your AndroidManifest.xml file. Any Java classes outside of that package that need to refer to R or BuildConfig need to add the corresponding import statement, as with any other Java class from a foreign package.
I have a problem with "Stacking Notifications For Android".
So, It was show error when i try to import "import android.preview.support.wearable.notifications.WearableNotifications;"
How to import this class?
Thx for your support.
--
[D]
Looks like some wear class names and packages have changed from the preview to the full sdk:
Since the APIs and package names have changed, the import statements at the top of MainActivity.java need to be adjusted like this:
-import android.preview.support.v4.app.NotificationManagerCompat;
-import android.preview.support.wearable.notifications.WearableNotifications;
+import android.support.v4.app.NotificationCompat;
+import android.support.v4.app.NotificationManagerCompat;
I had to explicitly add my "import R" to my main activity's source.
However, when I run the app nothing displays in the Emulator to let me know my app is running. I'm wondering if the "import" I added is wrong.
Assuming my package is named com.goSitOnAPotatoPanOtis.This.
should it be this:
import com.goSitOnAPotatoPanOtis.R;
or this:
import com.goSitOnAPotatoPanOtis.This.R;
?
From my experience you should not have to add an import *.R class, and it will actually cause problems when building. That class should be available to your activities already.
The R.java class is generated in the application package as defined by the manifest package attribute:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.goSitOnAPotatoPanOtis" android:versionCode="1"
android:versionName="1.00">
If your activity is in that package you do not need to import R.java because of Java package visibility. If your activity is in another package you need to import it with
import com.goSitOnAPotatoPanOtis.R;
Even if you import the R class when it is not necessary it should not cause your application to stop running.
It should be import com.goSitOnAPotatoPanOtis.R; you can then reference that R using just the R.id.some_id or whatever you are trying to reference from the generated R class.