Has anyone used 1GravityContactsPicker Library for android.
I just found this yesterday and decided to use this in my app due to its good features. I did everything as mentioned in the steps but when i am starting the activity I am getting a Toast message saying
Attribute undefined; "cp_textColorPrimary". Did you apply the correct
theme
i have checked the documentation of library and heres what i did
1) Added dependency to gradle
2) Added activity file to manifest
3) Enabled contacts permission
4) below is the code
Button button = (Button) findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent intent = new Intent(MainActivity.this, ContactPickerActivity.class)
.putExtra(ContactPickerActivity.EXTRA_THEME, R.style.ContactPicker_Theme_Dark)
.putExtra(ContactPickerActivity.EXTRA_CONTACT_BADGE_TYPE,
ContactPictureType.ROUND.name())
.putExtra(ContactPickerActivity.EXTRA_CONTACT_DESCRIPTION,
ContactDescription.ADDRESS.name())
.putExtra(ContactPickerActivity.EXTRA_SHOW_CHECK_ALL, true)
.putExtra(ContactPickerActivity.EXTRA_SELECT_CONTACTS_LIMIT, 0)
.putExtra(ContactPickerActivity.EXTRA_ONLY_CONTACTS_WITH_PHONE, false)
.putExtra(ContactPickerActivity.EXTRA_CONTACT_DESCRIPTION_TYPE,
ContactsContract.CommonDataKinds.Email.TYPE_WORK)
.putExtra(ContactPickerActivity.EXTRA_CONTACT_SORT_ORDER,
ContactSortOrder.AUTOMATIC.name());
startActivityForResult(intent, REQUEST_CONTACT);
}
});
can anyone please help me out with this
I have the same issue.
it's because in his Actvity he test the AppThem directly and if your Application themes does not implement Picker style the check is all time false.
// check if all custom attributes are defined
if (! checkTheming()) {
finish();
return;
}
For fix it, i've juste add new themes in styles.xml
<!-- LIGHT Theme -->
<style name="Theme_Light_Base" parent="#style/ContactPicker_Theme_Light">
<!-- ActionBarCompat -->
<item name="colorPrimary">#color/colorPrimary_light</item>
<item name="colorAccent">#color/colorAccent_light</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark_light</item>
<item name="backgroundColor">#color/background_light</item>
<!--<item name="icTheme">#drawable/ic_palette_black_36dp</item>-->
<!--<item name="icPickContact">#drawable/ic_person_add_black_36dp</item>-->
</style>
<style name="Theme_Light_picker" parent="#style/Theme_Light_Base"/>
<!-- DARK Theme -->
<style name="Theme_Dark_Base" parent="#style/ContactPicker_Theme_Dark">
<!-- ActionBarCompat -->
<item name="colorPrimary">#color/colorPrimary_dark</item>
<item name="colorAccent">#color/colorAccent_dark</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark_dark</item>
<item name="backgroundColor">#color/background_dark</item>
<!--<item name="icTheme">#drawable/ic_palette_white_36dp</item>-->
<!--<item name="icPickContact">#drawable/ic_person_add_white_36dp</item>-->
</style>
and after apply directly on the ActivityPicker in AndroidManifest.xml :
<activity
android:name="com.onegravity.contactpicker.core.ContactPickerActivity"
android:enabled="true"
android:exported="false"
android:theme="#style/Theme_Light_picker">
<intent-filter>
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
</activity>
Related
I am trying to load around 168kb (after optimization in tinypng.com) image as splash screen. Its crashing with below VERBOSE (no errors)-
W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
This is how I have implemented splash screen-
Activity:
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
//setContentView(R.layout.activity_splash1);--> Note this is commented
/* New Handler to start the Menu-Activity
* and close this Splash-Screen after some seconds.*/
new Handler().postDelayed(new Runnable(){
#Override
public void run() {
/* Create an Intent that will start the Menu-Activity. */
Intent mainIntent = new Intent(SplashActivity1.this,MainActivity.class);
SplashActivity1.this.startActivity(mainIntent);
SplashActivity1.this.finish();
}
}, SPLASH_DISPLAY_LENGTH);
}
Manifest Entry:
<activity
android:name=".ui.activities.SplashActivity1"
android:screenOrientation="portrait"
android:theme= "#style/AppTheme.NoActionBar.SplashActivity1">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Styles:
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorTheme</item>
<item name="colorAccent">#color/colorBlack</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.NoActionBar.SplashActivity1" parent="AppTheme.NoActionBar">
<item name="android:windowBackground">#drawable/splash1</item>
</style>
Drawable:
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="#drawable/bootpage">
</bitmap>
Running on: Android Emulator API 6
Thanks in Advance
There are two problems here .
1 - if you want your activity to be created without a layout (you have commented setContentView()) then you must use Theme.NoDispaly .
in your manifest :
<activity android:name = "MyActivity"
android:label = "#string/app_name"
android:theme = "#android:style/Theme.NoDisplay" >
2 - why you would call an activity without a ui ?
for splash pages the standard way is to to declare all your ccomponents and your drawables in xml like anyother activity.
i think there is no need not to use a layout in splash.
In my app, I am integrating progress dialogue and I am using below code for creating progress dialogue
public static void showProgressDialogue(final Context context, String title, String mainMessage) {
progressDialog = new ProgressDialog(context);
progressDialog.setTitle(title);
progressDialog.setMessage(mainMessage);
progressDialog.setIndeterminate(false);
progressDialog.show();
}
And I created 2 emulators one for lollipop and other for marsh mallow. It is showing title and message on lollipop emulator but not showing title and message on marsh mallow emulator. Further I have tried on real device as well. On marsh mallow (Motorolla droid turbo) device it is not showing title and message. For sake of giving complete understanding i am attaching images as well
Above images is taken of lollipop emulator
Above image is taken from marsh mallow emulator
I have googled a lot and could not fine suitable answer that solve my query. Even in one place I found that by changing 'textColorPrimary', it will work. But in my case it did not work. And below is my style.xml code
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="android:textColorPrimary">#color/black</item>
<item name="android:textViewStyle">#style/LoyaltyTextView</item>
<item name="editTextStyle">#style/LoyaltyEditText</item>
</style>
Any help?
As requested, I am posting my manifest as well
<?xml version="1.0" encoding="utf-8"?>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".views.activities.SplashActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"></action>
<category android:name="android.intent.category.LAUNCHER"></category>
</intent-filter>
</activity>
<activity android:name=".views.activities.MainActivity"/>
<activity android:name=".views.activities.LoginActivity"/>
<activity android:name=".views.activities.SignUpActivity"/>
<activity android:name=".views.activities.ViewAsGuest"/>
<activity android:name=".views.activities.BusinessActivity"/>
</application>
I have create demo application in Android Studio with two Activity. In First Activity Show Title Bar in preview as well as in emulator but on second Activity does not show Title Bar in Emulator but it display in preview. I have used API 22 in Android Studio.
Please help me....thanx in advn
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/BaseTheme">
<activity
android:name=".MainActivity"
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=".DrawingActivity"
android:label="#string/app_name"
android:theme="#style/BaseTheme"
android:screenOrientation="portrait" />
</application>
Theme style file like this....
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>
<style name="BaseTheme" parent="AppTheme">
<item name="colorPrimary">#color/action_bar_backgound</item>
</style>
I have also try this...
First Activity Work's fine so I have set that in Second Activity as a setContentView(R.layout.activity_main);
MainActivity.java
public class MainActivity extends ActionBarActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void buttonAction(View v) {
Intent intent = new Intent(MainActivity.this, DrawingActivity.class);
startActivity(intent);
}
}
DrawActivity.java
public class DrawingActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
What you are facing is a bug related to the API 22(5.1) SDK.
Kindly refer the following links for the details on the bug in which the Action Bar is not displayed:
https://code.google.com/p/android/issues/detail?id=159793
https://code.google.com/p/android/issues/detail?id=159780
What you can do for now
Either revert back to API 21 if possible or,
Select API 21 in the compile with (render with) option in Android Studio.
Hope this helps.
There are a lot of similar questions on StackOverfow but they don't solve my problem.
The task is to process in Service intents sent with default share mechanism (ACTION_SEND) from different applications.
But as far as ACTION_SEND is an activity action we have to pick up intent in activity and broadcast it to service. And it will be perfect if this activity will be invisible to the user.
I've researched a lot and have tried many solutions already.
First step of making activity invisible belongs to activity style.
I've tried this values.
android:theme="#android:style/Theme.Translucent.NoTitleBar"
android:theme="#android:style/Theme.Translucent"
android:theme="#android:style/Theme.Translucent.NoTitleBar.Fullscreen"
Also i"ve tried to create a custom theme.
<style name="Theme.Transparent" parent="android:Theme">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:backgroundDimEnabled">true</item>
</style>
How the activity in AndroidManifest.xml looks like.
<activity
android:name="xxx.xxx.activities.HandleShareIntentActivity"
android:theme="#style/Theme.Transparent"
android:noHistory="true"
android:excludeFromRecents="true"
android:label="#string/title_activity_handle_share_intent">
<intent-filter>
<action android:name="com.google.android.gm.action.AUTO_SEND"/>
<action android:name="android.intent.action.SEND"/>
<action android:name="android.intent.action.SEND_MULTIPLE"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="com.google.android.voicesearch.SELF_NOTE"/>
<data android:mimeType="*/*"/>
</intent-filter>
</activity>
Activity code. No setContentView(). finish() in onCreate().
public class HandleShareIntentActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
startService(new Intent(this, xxxService.class).putExtra(
Constants.ACTION_SHARE_KEY, getIntent()));
finish();
}
}
On Nexus 5, android 4.4.4 I do have black screen blink while handling any share event.
Any solutions?
I've tried this values.
Use Theme.NoDisplay.
I Just did this, and it helped in my case:
<activity
android:name=".SensorBoardActivity"
android:theme="#android:style/Theme.NoDisplay"
android:excludeFromRecents="true"
android:noHistory="true">
I see you already have finish(); but just for others it is important to execute it just before leaving the onCreate().
My Activitys use a theme which set android:windowNoTitle = true.But I have to show the title in some activities. I want show the title in my activity by call requestWindowFeature(), but it's not work! Any help would be great.
Thanks.
ps:
My activitys hava to be switched between two themes.The homeActivty use the actionbar and others no title.These activtys are use the same themes.So when before use requestWindowFeature() it's been hiding, and i just want show it now.
Here is my codes:
Defined theme:
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
<item name="android:windowAnimationStyle">#style/activityAnimation</item>
<item name="android:windowNoTitle">true</item>
<!-- <item name="android:background">#color/background_holo_light</item> -->
</style>
And use the theme in application:
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
Get and change the theme if necessary:
int mThemeId = mSettingPreferences.getInt(MySettings.THEME_ID, -1);
if (-1 != mThemeId) {
this.setTheme(mThemeId);
}
// do something to show the title
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.yourlayout);
You don't need to apply any Theme if you use this.
you have to use this method before your setContentView method...
requestWindowFeature(Window.FEATURE_NO_TITLE);
OR
And yes you can add theme in Manifest file in which Activity you don't want to Title..Then use this..
<activity
android:name=".activity name"
android:theme="#android:style/Theme.Black.NoTitleBar"
android:screenOrientation="potrait" >
</activity>
first change this:
if (mThemeId != -1) {
this.setTheme(mThemeId);
}
and after that you can use
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
<activity
android:name=".HistoryImage"
android:screenOrientation="sensorPortait"
android:theme="#android:style/Theme.Black.NoTitleBar" >
</activity>
<activity
android:name=".HistoryVideo"
android:screenOrientation="sensorPortait" >
</activity>
<activity
android:name=".HistoryVideo_2"
android:theme="#android:style/Theme.Black.NoTitleBar"
android:screenOrientation="sensorPortait" >
</activity>
you must call requestWindowFeature(); before setContentView()
The activities in which you don't want to show the title bar. just do this to hide the title bar. befor setcontentView requestWindowFeature(Window.FEATURE_NO_TITLE);
I hope this will help you
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_page);