问题描述
我正在尝试与Viber联系。使用这种方法,我可以获得使用Viber的联系人的姓名,也可以得到不使用Viber的其他联系人的姓名(选择方法无法正常工作)。我也无法获得Viber的联系人号码。知道如何解决此问题吗?
import React,{useRef} from 'react';
import Title from './title';
import { CSSTransition } from 'react-transition-group';
import { Route} from 'react-router-dom';
import {gsap} from "gsap";
const Home = () => {
// These two Refs are needed to refer to elements that we will be animating
const title = useRef(null)
const info = useRef(null)
// This Ref will be used to make reference to the page of each component.
// My understanding is that this Ref will be used to distinguish between each
// component that is using 'CSSTransition' component and also removes the
// 'findDOMNode' warning
const nodeRef = useRef(null)
// This function is called immediately after the 'enter'
// or 'appear' class is applied from CSSTransition component.
const onEnter = () => {
gsap.from(
[title.current,info.current],{
duration: 0.6,y: 30,delay: 0.6,ease: 'power3.inOut',opacity: 0,stagger: {
amount: 0.3,},}
);
};
// This function is called immediately after the 'exit'
// class is applied from CSSTransition component.
const onExit = () => {
gsap.to(
[title.current,y: -30,stagger: {
amount: 0.15,}
);
};
return (
<Route
exact path={'/'}
children={({ match }) => (
<CSSTransition
in={match != null}
// time should not really be longer than the time it takes the animation
// to leave the scene.
timeout={1200}
classNames={'page'}
nodeRef={nodeRef}
onEnter={onEnter}
onExit={onExit}
unmountOnExit
>
<div className={'page'} ref={nodeRef}>
<div className="inner">
<Title forwardRef={title} lineContent="this is the" lineContent2="Home page" />
<div ref={info} className={'infoBox'}>
<p className="info">hello stackOverflow and welcome</p>
</div>
</div>
</div>
</CSSTransition>
)}
/>
);
};
export default Home;
解决方法
我相信这段代码应该对您有用:
String MIMETYPE_VIBER_MESSAGE = "vnd.android.cursor.item/vnd.com.viber.voip.viber_number_message";
String selection = Data.MIMETYPE + "=?";
String[] selectionArgs = new String[] { MIMETYPE_VIBER_MESSAGE };
String[] projection = new String[] { Data.CONTACT_ID,Data.DATA1,Data.DISPLAY_NAME };
Cursor cur = getContentResolver().query(Data.CONTENT_URI,projection,selection,selectionArgs,null);
DatabaseUtils.dumpCursor(cur); // check logcat for the results